Merge branch 'master' of https://gitlab.principis.be/OGP/worms
This commit is contained in:
@@ -1,64 +1,71 @@
|
||||
package worms.facade;
|
||||
|
||||
import worms.model.Food;
|
||||
import worms.model.Team;
|
||||
import worms.model.Worm;
|
||||
import worms.util.IllegalNameException;
|
||||
import worms.util.ModelException;
|
||||
import worms.util.Tuple;
|
||||
import worms.util.Coordinate;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class Facade implements IFacade {
|
||||
/**
|
||||
* Create and return a new worm that is positioned at the given location, looks
|
||||
* in the given direction, has the given radius and the given name.
|
||||
*
|
||||
* @param location
|
||||
* An array containing the x-coordinate of the position of the new
|
||||
* worm followed by the y-coordinate of the position of the new worm
|
||||
* (in meter)
|
||||
* @param direction
|
||||
* The direction of the new worm (in radians)
|
||||
* @param radius
|
||||
* The radius of the new worm (in meter)
|
||||
* @param name
|
||||
* the name of the new worm
|
||||
* @post the new worm has the given location, direction, name and radius
|
||||
* |new Worm(Tuple.create(location), direction, name, radius)
|
||||
* @throws ModelException
|
||||
* the worm throws an IllegalArgumentException
|
||||
* |catch(IllegalArgumentException e)
|
||||
*/
|
||||
@Override
|
||||
public Worm createWorm(double[] location, double direction, double radius, String name) throws ModelException {
|
||||
// /**
|
||||
// * Create and return a new worm that is positioned at the given location, looks
|
||||
// * in the given direction, has the given radius and the given name.
|
||||
// *
|
||||
// * @param location
|
||||
// * An array containing the x-coordinate of the position of the new
|
||||
// * worm followed by the y-coordinate of the position of the new worm
|
||||
// * (in meter)
|
||||
// * @param direction
|
||||
// * The direction of the new worm (in radians)
|
||||
// * @param radius
|
||||
// * The radius of the new worm (in meter)
|
||||
// * @param name
|
||||
// * the name of the new worm
|
||||
// * @post the new worm has the given location, direction, name and radius
|
||||
// * |new Worm(Coordinate.create(location), direction, name, radius)
|
||||
// * @throws ModelException
|
||||
// * the worm throws an IllegalArgumentException
|
||||
// * |catch(IllegalArgumentException e)
|
||||
// */
|
||||
// @Override
|
||||
// public Worm createWorm(double[] location, double direction, double radius, String name) throws ModelException {
|
||||
//
|
||||
// try {
|
||||
// return new Worm(Coordinate.create(location), direction, name, radius);
|
||||
// }
|
||||
// catch(IllegalArgumentException e) {
|
||||
// throw new ModelException(e);
|
||||
// }
|
||||
// }
|
||||
|
||||
try {
|
||||
return new Worm(Tuple.create(location), direction, name, radius);
|
||||
}
|
||||
catch(IllegalArgumentException e) {
|
||||
throw new ModelException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the given worm by the given number of steps.
|
||||
*
|
||||
* @param worm
|
||||
* the worm who is going to move
|
||||
* @param nbSteps
|
||||
* the number of steps the worm is going to take
|
||||
* @post the worm has taken the given number of steps
|
||||
* |worm.move(nbSteps)
|
||||
* @throws ModelException
|
||||
* the worm throws an IllegalArgumentException
|
||||
* |catch(IllegalArgumentException e)
|
||||
*/
|
||||
@Override
|
||||
public void move(Worm worm, int nbSteps) throws ModelException {
|
||||
try {
|
||||
worm.move(nbSteps);
|
||||
}
|
||||
catch(IllegalArgumentException e) {
|
||||
throw new ModelException(e);
|
||||
}
|
||||
}
|
||||
// /**
|
||||
// * Moves the given worm by the given number of steps.
|
||||
// *
|
||||
// * @param worm
|
||||
// * the worm who is going to move
|
||||
// * @param nbSteps
|
||||
// * the number of steps the worm is going to take
|
||||
// * @post the worm has taken the given number of steps
|
||||
// * |worm.move(nbSteps)
|
||||
// * @throws ModelException
|
||||
// * the worm throws an IllegalArgumentException
|
||||
// * |catch(IllegalArgumentException e)
|
||||
// */
|
||||
// @Override
|
||||
// public void move(Worm worm, int nbSteps) throws ModelException {
|
||||
// try {
|
||||
// worm.move(nbSteps);
|
||||
// }
|
||||
// catch(IllegalArgumentException e) {
|
||||
// throw new ModelException(e);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Turns the given worm by the given angle.
|
||||
@@ -77,46 +84,89 @@ public class Facade implements IFacade {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the given worm jump.
|
||||
*
|
||||
* Return the location the farthest away from its current location to which the given
|
||||
* worm can move in the world in which that worm is positioned, if any, following
|
||||
* the given direction and not exceeding the given maximum distance.
|
||||
* - The maximum distance must be finite and may not be negative.
|
||||
* - The given direction must be in the range [0.0 .. PI[.
|
||||
* - On its road to the resulting location, the given worm will always be
|
||||
* positioned on passable terrain.
|
||||
* - The resulting position may be outside the boundaries of the world, if any, in
|
||||
* which the given worm is located.
|
||||
*
|
||||
* @param worm
|
||||
* the worm who is going to move
|
||||
* @post the worm has jumped
|
||||
* @throws ModelException
|
||||
* the worm throws an IllegalStateException
|
||||
* |catch(IllegalStateException e)
|
||||
* @param direction
|
||||
* @param maxDistance
|
||||
*/
|
||||
@Override
|
||||
public void jump(Worm worm) throws ModelException {
|
||||
try {
|
||||
worm.jump();
|
||||
}
|
||||
catch(IllegalStateException e) {
|
||||
throw new ModelException(e);
|
||||
}
|
||||
public double[] getFurthestLocationInDirection(Worm worm, double direction, double maxDistance) throws ModelException {
|
||||
return new double[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total amount of time (in seconds) that a jump of the given worm
|
||||
* would take.
|
||||
*
|
||||
* Move the given worm according to the rules in the assignment.
|
||||
*
|
||||
* @param worm
|
||||
* the worm who is going to move
|
||||
* @throws ModelException
|
||||
* the worm throws an IllegalStateException
|
||||
* |catch(IllegalStateException e)
|
||||
*/
|
||||
@Override
|
||||
public double getJumpTime(Worm worm) throws ModelException {
|
||||
public void move(Worm worm) throws ModelException {
|
||||
|
||||
try {
|
||||
return worm.jumpTime();
|
||||
}
|
||||
catch(IllegalStateException e) {
|
||||
throw new ModelException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the time needed by the given worm to jump to the nearest position
|
||||
* adjacent to impassable terrain.
|
||||
* - deltaT determines the resolution to be used in successive steps of the jump.
|
||||
*
|
||||
* @param worm
|
||||
* @param deltaT
|
||||
*/
|
||||
@Override
|
||||
public double getJumpTime(Worm worm, double deltaT) throws ModelException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Makes the given worm jump.
|
||||
// *
|
||||
// * @param worm
|
||||
// * the worm who is going to move
|
||||
// * @post the worm has jumped
|
||||
// * @throws ModelException
|
||||
// * the worm throws an IllegalStateException
|
||||
// * |catch(IllegalStateException e)
|
||||
// */
|
||||
// @Override
|
||||
// public void jump(Worm worm) throws ModelException {
|
||||
// try {
|
||||
// worm.jump();
|
||||
// }
|
||||
// catch(IllegalStateException e) {
|
||||
// throw new ModelException(e);
|
||||
// }
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Returns the total amount of time (in seconds) that a jump of the given worm
|
||||
// * would take.
|
||||
// *
|
||||
// * @param worm
|
||||
// * the worm who is going to move
|
||||
// * @throws ModelException
|
||||
// * the worm throws an IllegalStateException
|
||||
// * |catch(IllegalStateException e)
|
||||
// */
|
||||
// @Override
|
||||
// public double getJumpTime(Worm worm) throws ModelException {
|
||||
//
|
||||
// try {
|
||||
// return worm.jumpTime();
|
||||
// }
|
||||
// catch(IllegalStateException e) {
|
||||
// throw new ModelException(e);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Returns the location on the jump trajectory of the given worm after a time t.
|
||||
*
|
||||
@@ -134,7 +184,7 @@ public class Facade implements IFacade {
|
||||
public double[] getJumpStep(Worm worm, double t) throws ModelException {
|
||||
|
||||
try {
|
||||
Tuple<Double, Double> jumpStep = worm.jumpStep(t);
|
||||
Coordinate jumpStep = worm.jumpStep(t);
|
||||
return new double[]{jumpStep.item1, jumpStep.item2};
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
@@ -143,25 +193,436 @@ public class Facade implements IFacade {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the x-coordinate of the current location of the given worm.
|
||||
*
|
||||
* Make the given worm jump using the given time step.
|
||||
* - The given time step determines a time interval during which
|
||||
* you may assume that the worm will not move through a piece
|
||||
* of impassable terrain.
|
||||
*
|
||||
* @param worm
|
||||
* the worm who is going to move
|
||||
* @param timeStep
|
||||
*/
|
||||
@Override
|
||||
public double getX(Worm worm) throws ModelException {
|
||||
return worm.getLocation().item1;
|
||||
public void jump(Worm worm, double timeStep) throws ModelException {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the y-coordinate of the current location of the given worm.
|
||||
*
|
||||
* @param worm
|
||||
* the worm who is going to move
|
||||
* Create and return a new portion of food that is positioned at the given
|
||||
* location in the given world.
|
||||
* = If the given world is not effective, the new food is simply positioned
|
||||
* at the given location.
|
||||
*
|
||||
* @param world
|
||||
* @param location
|
||||
*/
|
||||
@Override
|
||||
public double getY(Worm worm) throws ModelException {
|
||||
return worm.getLocation().item2;
|
||||
public Food createFood(World world, double[] location) throws ModelException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Terminate the given portion of food.
|
||||
*
|
||||
* @param food
|
||||
*/
|
||||
@Override
|
||||
public void terminate(Food food) throws ModelException {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the given portion of food is terminated.
|
||||
*
|
||||
* @param food
|
||||
*/
|
||||
@Override
|
||||
public boolean isTerminated(Food food) throws ModelException {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current location of the given portion of food.
|
||||
* - The resulting array contains the the x-coordinate of the given worm
|
||||
* followed by its y-coordinate.
|
||||
*
|
||||
* @param food
|
||||
*/
|
||||
@Override
|
||||
public double[] getLocation(Food food) throws ModelException {
|
||||
return new double[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the radius of the given portion of food.
|
||||
*
|
||||
* @param food
|
||||
*/
|
||||
@Override
|
||||
public double getRadius(Food food) throws ModelException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the mass of the given portion of food.
|
||||
*
|
||||
* @param food
|
||||
*/
|
||||
@Override
|
||||
public double getMass(Food food) throws ModelException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the world to which this portion of food belongs.
|
||||
*
|
||||
* @param food
|
||||
*/
|
||||
@Override
|
||||
public World getWorld(Food food) throws ModelException {
|
||||
return null;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Returns the x-coordinate of the current location of the given worm.
|
||||
// *
|
||||
// * @param worm
|
||||
// * the worm who is going to move
|
||||
// */
|
||||
// @Override
|
||||
// public double getX(Worm worm) throws ModelException {
|
||||
// return worm.getLocation().item1;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Returns the y-coordinate of the current location of the given worm.
|
||||
// *
|
||||
// * @param worm
|
||||
// * the worm who is going to move
|
||||
// */
|
||||
// @Override
|
||||
// public double getY(Worm worm) throws ModelException {
|
||||
// return worm.getLocation().item2;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Create a new world with given width and given height.
|
||||
* The passable map is a rectangular matrix indicating which parts of the terrain
|
||||
* are passable and which parts are impassable.
|
||||
* This matrix is derived from the transparency of the pixels in the image file
|
||||
* of the terrain. passableMap[r][c] is true if the location at row r and column c
|
||||
* is passable, and false if that location is impassable.
|
||||
* The elements in the first row (row 0) represent the pixels at the top of the
|
||||
* terrain (i.e., largest y-coordinates).
|
||||
* The elements in the last row (row passableMap.length-1) represent pixels at the
|
||||
* bottom of the terrain (smallest y-coordinates).
|
||||
* The elements in the first column (column 0) represent the pixels at the left
|
||||
* of the terrain (i.e., smallest x-coordinates).
|
||||
* The elements in the last column (column passableMap[0].length-1) represent the
|
||||
* pixels at the right of the terrain (i.e., largest x-coordinates).
|
||||
*
|
||||
* @param width
|
||||
* @param height
|
||||
* @param passableMap
|
||||
*/
|
||||
@Override
|
||||
public World createWorld(double width, double height, boolean[][] passableMap) throws ModelException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Terminate the given world.
|
||||
*
|
||||
* @param world
|
||||
*/
|
||||
@Override
|
||||
public void terminate(World world) throws ModelException {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the given worls is terminated.
|
||||
*
|
||||
* @param world
|
||||
*/
|
||||
@Override
|
||||
public boolean isTerminated(World world) throws ModelException {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the width of the given world.
|
||||
*
|
||||
* @param world
|
||||
*/
|
||||
@Override
|
||||
public double getWorldWidth(World world) throws ModelException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the height of the given world.
|
||||
*
|
||||
* @param world
|
||||
*/
|
||||
@Override
|
||||
public double getWorldHeight(World world) throws ModelException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the given world is passable at the given location.
|
||||
* - The location is an array containing the x-coordinate of the location to
|
||||
* check followed by the y-coordinate of that location.
|
||||
* - Locations outside the boundaries of the world are always passable.
|
||||
*
|
||||
* @param world
|
||||
* @param location
|
||||
*/
|
||||
@Override
|
||||
public boolean isPassable(World world, double[] location) throws ModelException {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* <<<<<<< HEAD
|
||||
* Create and return a new worm that is positioned at the given location, looks
|
||||
* in the given direction, has the given radius and the given name.
|
||||
*
|
||||
* @param world
|
||||
* @param center
|
||||
* @param radius The radius of the new worm (in meter)
|
||||
*/
|
||||
@Override
|
||||
public boolean isPassable(World world, double[] center, double radius) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the circular area with given center and given radius
|
||||
* is adjacent to impassable terrain in the given world.
|
||||
* - The circular area must not lie completely within the given world.
|
||||
*
|
||||
* @param world
|
||||
* @param center
|
||||
* @param radius
|
||||
*/
|
||||
@Override
|
||||
public boolean isAdjacent(World world, double[] center, double radius) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the given world contains the given worm.
|
||||
*
|
||||
* @param world
|
||||
* @param worm
|
||||
*/
|
||||
@Override
|
||||
public boolean hasAsWorm(World world, Worm worm) throws ModelException {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given worm to the given world.
|
||||
*
|
||||
* @param world
|
||||
* @param worm
|
||||
*/
|
||||
@Override
|
||||
public void addWorm(World world, Worm worm) throws ModelException {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given worm from the given world.
|
||||
*
|
||||
* @param world
|
||||
* @param worm
|
||||
*/
|
||||
@Override
|
||||
public void removeWorm(World world, Worm worm) throws ModelException {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list filled with all the worms in the given world.
|
||||
*
|
||||
* @param world
|
||||
*/
|
||||
@Override
|
||||
public List<Worm> getAllWorms(World world) throws ModelException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the given world contains the given food.
|
||||
*
|
||||
* @param world
|
||||
* @param food
|
||||
*/
|
||||
@Override
|
||||
public boolean hasAsFood(World world, Food food) throws ModelException {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given portion of food to the given world.
|
||||
*
|
||||
* @param world
|
||||
* @param food
|
||||
*/
|
||||
@Override
|
||||
public void addFood(World world, Food food) throws ModelException {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given portion of food from the given world.
|
||||
*
|
||||
* @param world
|
||||
* @param food
|
||||
*/
|
||||
@Override
|
||||
public void removeFood(World world, Food food) throws ModelException {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a collection filled with all the worms and all the
|
||||
* portions of food in the given world.
|
||||
*
|
||||
* @param world
|
||||
*/
|
||||
@Override
|
||||
public Collection<Object> getAllItems(World world) throws ModelException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a set of all the team in the given world.
|
||||
*
|
||||
* @param world
|
||||
*/
|
||||
@Override
|
||||
public Set<Team> getAllTeams(World world) throws ModelException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the given world has an active game.
|
||||
*
|
||||
* @param world
|
||||
*/
|
||||
@Override
|
||||
public boolean hasActiveGame(World world) throws ModelException {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the active worm in the given world.
|
||||
* - The active worm is the worm whose turn it is to perform
|
||||
* player-controlled actions.
|
||||
*
|
||||
* @param world
|
||||
*/
|
||||
@Override
|
||||
public Worm getActiveWorm(World world) throws ModelException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a new game in the given world.
|
||||
*
|
||||
* @param world
|
||||
*/
|
||||
@Override
|
||||
public void startGame(World world) throws ModelException {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish the current game, if any, in the given world.
|
||||
*
|
||||
* @param world
|
||||
*/
|
||||
@Override
|
||||
public void finishGame(World world) throws ModelException {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate the next worm in the given world.
|
||||
*
|
||||
* @param world
|
||||
*/
|
||||
@Override
|
||||
public void activateNextWorm(World world) throws ModelException {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of a single worm if that worm is the winner, or the name
|
||||
* of a team if that team is the winner and the team still has several members.
|
||||
*
|
||||
* @param world
|
||||
*/
|
||||
@Override
|
||||
public String getWinner(World world) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and return a new worm that is positioned at the given location in
|
||||
* the given world, that looks in the given direction, that has the given radius
|
||||
* and the given name, and that is a member of the given team.
|
||||
* - If the given world is not effective, the new worm is simply positioned
|
||||
* at the given location.
|
||||
* - If the given team is not effective, the new worm is not part of any team.
|
||||
* The location is an array containing the x-coordinate of the location of
|
||||
* the new worm followed by the y-coordinate of that location.
|
||||
*
|
||||
* @param world
|
||||
* @param location
|
||||
* @param direction
|
||||
* @param radius
|
||||
* @param name
|
||||
* @param team
|
||||
*/
|
||||
@Override
|
||||
public Worm createWorm(World world, double[] location, double direction, double radius, String name, Team team) throws ModelException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Terminate the given worm.
|
||||
*
|
||||
* @param worm
|
||||
*/
|
||||
@Override
|
||||
public void terminate(Worm worm) throws ModelException {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the given worm is terminated.
|
||||
*
|
||||
* @param worm
|
||||
*/
|
||||
@Override
|
||||
public boolean isTerminated(Worm worm) throws ModelException {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current location of the given worm.
|
||||
* - The resulting array contains the the x-coordinate of the given worm
|
||||
* followed by its y-coordinate.
|
||||
*
|
||||
* @param worm
|
||||
*/
|
||||
@Override
|
||||
public double[] getLocation(Worm worm) throws ModelException {
|
||||
return new double[0];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,6 +697,29 @@ public class Facade implements IFacade {
|
||||
worm.decreaseActionPoints((int) delta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current number of hit points of the given worm.
|
||||
*
|
||||
* @param worm
|
||||
*/
|
||||
@Override
|
||||
public BigInteger getNbHitPoints(Worm worm) throws ModelException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the current number of hit points of the given worm
|
||||
* with the given delta.
|
||||
* - The given delta may be negative.
|
||||
*
|
||||
* @param worm
|
||||
* @param delta
|
||||
*/
|
||||
@Override
|
||||
public void incrementNbHitPoints(Worm worm, long delta) throws ModelException {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum number of action points of the given worm.
|
||||
*
|
||||
@@ -281,6 +765,16 @@ public class Facade implements IFacade {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the world to which this worm belongs
|
||||
*
|
||||
* @param worm
|
||||
*/
|
||||
@Override
|
||||
public World getWorld(Worm worm) throws ModelException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mass of the given worm.
|
||||
*
|
||||
|
4
OGP1718-Worms/src/worms/facade/World.java
Normal file
4
OGP1718-Worms/src/worms/facade/World.java
Normal file
@@ -0,0 +1,4 @@
|
||||
package worms.facade;
|
||||
|
||||
public class World {
|
||||
}
|
@@ -31,6 +31,24 @@ public class Coordinate extends Tuple<Double, Double> {
|
||||
return new Coordinate(coordinateX, coordinateY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new Coordinate created from the elements of the array.
|
||||
*
|
||||
* @param arr
|
||||
* The Array to create the Coordinate of.
|
||||
* @return The Tuple created from the elements of the given array.
|
||||
* | result == new Coordinate(arr[0], arr[1])
|
||||
* @throws IllegalArgumentException
|
||||
* The given array is null or the length of the given array
|
||||
* is not 2.
|
||||
* | arr == null || arr.length != 2
|
||||
*/
|
||||
@Immutable
|
||||
public static Coordinate create(double[] arr) throws IllegalArgumentException {
|
||||
if (arr == null || arr.length != 2)
|
||||
throw new IllegalArgumentException("Invalid parameter arr");
|
||||
return new Coordinate(arr[0], arr[1]);
|
||||
}
|
||||
@Basic @Immutable
|
||||
public double getCoordinateX() {
|
||||
return this.item1;
|
||||
|
Reference in New Issue
Block a user