Documentatie Coordinate

This commit is contained in:
Leen Dereu
2018-05-24 12:14:45 +02:00
parent 552ed3ac94
commit 5c64518c41

View File

@@ -6,11 +6,18 @@ import be.kuleuven.cs.som.annotate.Value;
@Value @Value
public class Coordinate extends Tuple<Double, Double> { public class Coordinate extends Tuple<Double, Double> {
/** /**
* Initialize this new Tuple as a Tuple with the given items. * @param coordinateX
* @param coordinateY
* *
* @param coordinateX The x-coordinate for this Coordinate * @post ...
* @param coordinateY The y-coordinate for this Coordinate * |new.this.item1 == coordinateX
* @post ...
* |new.this.item2 == coordinateY
*
* @throws IllegalArgumentException ...
* |
*/ */
public Coordinate(double coordinateX, double coordinateY) throws IllegalArgumentException { public Coordinate(double coordinateX, double coordinateY) throws IllegalArgumentException {
super(coordinateX, coordinateY); super(coordinateX, coordinateY);
@@ -19,12 +26,10 @@ public class Coordinate extends Tuple<Double, Double> {
/** /**
* *
* @param coordinateX * @param coordinateX
* The value for the x-coordinate.
* @param coordinateY * @param coordinateY
* The value for the y-coordinate. *
* @return * @return ...
* The coordinate created from coordinateX and coordinateY. * |result == new Coordinate(coordinateX, coordinateY);
* | result == new Coordinate(coordinateX, coordinateY);
*/ */
@Immutable @Immutable
public static Coordinate create(double coordinateX, double coordinateY){ public static Coordinate create(double coordinateX, double coordinateY){
@@ -32,16 +37,13 @@ public class Coordinate extends Tuple<Double, Double> {
} }
/** /**
* Return a new Coordinate created from the elements of the array.
*
* @param arr * @param arr
* The Array to create the Coordinate of. *
* @return The Tuple created from the elements of the given array. * @return ...
* | result == new Coordinate(arr[0], arr[1]) * |result == new Coordinate(arr[0], arr[1])
* @throws IllegalArgumentException *
* The given array is null or the length of the given array * @throws IllegalArgumentException ...
* is not 2. * |arr == null || arr.length != 2
* | arr == null || arr.length != 2
*/ */
@Immutable @Immutable
public static Coordinate create(double[] arr) throws IllegalArgumentException { public static Coordinate create(double[] arr) throws IllegalArgumentException {
@@ -50,15 +52,27 @@ public class Coordinate extends Tuple<Double, Double> {
return new Coordinate(arr[0], arr[1]); return new Coordinate(arr[0], arr[1]);
} }
/**
* @return ...
* |result == new double[]{getX(), getY()}
*/
public double[] toArray() { public double[] toArray() {
return new double[]{getX(), getY()}; return new double[]{getX(), getY()};
} }
/**
* @return ...
* |result == this.item1
*/
@Basic @Immutable @Basic @Immutable
public double getX() { public double getX() {
return this.item1; return this.item1;
} }
/**
* @return ...
* |result == this.item2
*/
@Basic @Immutable @Basic @Immutable
public double getY() { public double getY() {
return this.item2; return this.item2;