Merge branch 'master' of gitlab.principis.be:OGP/worms
This commit is contained in:
@@ -1,5 +1,14 @@
|
|||||||
public class Worm {
|
public class Worm {
|
||||||
|
/**
|
||||||
|
* a class with the specifications of the worm
|
||||||
|
*
|
||||||
|
* @invar the location of the worm must be a valid location
|
||||||
|
* |...
|
||||||
|
* @invar
|
||||||
|
*
|
||||||
|
* @version 1.0
|
||||||
|
* @author Arthur Bols and Leen Dereu
|
||||||
|
*/
|
||||||
|
|
||||||
// region properties
|
// region properties
|
||||||
//===================================================================================
|
//===================================================================================
|
||||||
@@ -9,20 +18,39 @@ public class Worm {
|
|||||||
private Tuple<Double, Double> location;
|
private Tuple<Double, Double> location;
|
||||||
private Tuple<Double, Double> oldLocation;
|
private Tuple<Double, Double> oldLocation;
|
||||||
|
|
||||||
// Orientation
|
/**
|
||||||
|
* this variable contains the orientation of the worm
|
||||||
|
*/
|
||||||
private double orientation;
|
private double orientation;
|
||||||
|
|
||||||
// shape
|
/**
|
||||||
|
* this variable contains the radius of the worm
|
||||||
|
*/
|
||||||
private double radius;
|
private double radius;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this variable contains the minimum value of the radius
|
||||||
|
*/
|
||||||
private final double minRadius;
|
private final double minRadius;
|
||||||
// mass
|
|
||||||
|
/**
|
||||||
|
* this variable contains the mass of the worm
|
||||||
|
*/
|
||||||
private double mass;
|
private double mass;
|
||||||
|
|
||||||
// points
|
/**
|
||||||
|
* this variable contains the current action points of the worm
|
||||||
|
*/
|
||||||
private int points;
|
private int points;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this variable contains the maximum points a worm can have
|
||||||
|
*/
|
||||||
private int maxPoints;
|
private int maxPoints;
|
||||||
|
|
||||||
// name
|
/**
|
||||||
|
* this variable contains the name of the worm
|
||||||
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
//===================================================================================
|
//===================================================================================
|
||||||
@@ -86,6 +114,13 @@ public class Worm {
|
|||||||
return this.location;
|
return this.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the location of the worm to the given location
|
||||||
|
*
|
||||||
|
* @param location
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException
|
||||||
|
*/
|
||||||
private void setLocation(Tuple<Double, Double> location) throws IllegalArgumentException {
|
private void setLocation(Tuple<Double, Double> location) throws IllegalArgumentException {
|
||||||
|
|
||||||
if (location.equals(null))
|
if (location.equals(null))
|
||||||
@@ -101,14 +136,25 @@ public class Worm {
|
|||||||
//===================================================================================
|
//===================================================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param orientation
|
* set the orientation of the worm to the given orientation
|
||||||
* | ...
|
|
||||||
*
|
*
|
||||||
|
* @param orientation
|
||||||
|
* the new orientation of the worm
|
||||||
|
* @pre the given orientation must be a valid orientation for any worm
|
||||||
|
* |isValidOrientation(orientation)
|
||||||
|
* @post the new orientation of the worm must be equal to the given orientation
|
||||||
|
* |new.getOrientation() == orientation
|
||||||
*/
|
*/
|
||||||
public void setOrientation(double orientation) {
|
public void setOrientation(double orientation) {
|
||||||
|
|
||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the orientation of the worm
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Basic
|
||||||
public double getOrientation() {
|
public double getOrientation() {
|
||||||
return orientation;
|
return orientation;
|
||||||
}
|
}
|
||||||
@@ -122,10 +168,19 @@ public class Worm {
|
|||||||
// region Shape mass/radius
|
// region Shape mass/radius
|
||||||
//===================================================================================
|
//===================================================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the radius of the worm
|
||||||
|
*/
|
||||||
|
@Basic
|
||||||
public double getRadius() {
|
public double getRadius() {
|
||||||
return this.radius;
|
return this.radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param radius
|
||||||
|
* @throws IllegalArgumentException
|
||||||
|
*/
|
||||||
public void setRadius(double radius) throws IllegalArgumentException {
|
public void setRadius(double radius) throws IllegalArgumentException {
|
||||||
if (radius < this.minRadius)
|
if (radius < this.minRadius)
|
||||||
throw new IllegalArgumentException("Radius is smaller than " + this.minRadius);
|
throw new IllegalArgumentException("Radius is smaller than " + this.minRadius);
|
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
### orientation
|
### orientation
|
||||||
orientation hoek theta (radialen)
|
orientation hoek theta (radialen)
|
||||||
rechts: 0 boven: pi/2
|
rechts: th0 boven: pi/2
|
||||||
nominaal
|
nominaal
|
||||||
0..2pi
|
0..2pi
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user