small improvements
This commit is contained in:
@@ -295,6 +295,7 @@ public class Worm {
|
||||
return this.actionPoints;
|
||||
}
|
||||
|
||||
@Basic
|
||||
public long getMaxActionPoints() {
|
||||
return this.maxActionPoints;
|
||||
}
|
||||
@@ -410,30 +411,11 @@ public class Worm {
|
||||
* Return the name of the worm
|
||||
* the name of the worm expresses the identity of the worm
|
||||
*/
|
||||
@Basic
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the name of the worm tot the given name
|
||||
*
|
||||
* @param name
|
||||
* the new name for the worm
|
||||
* @post the new name of the worm is equal to the given name
|
||||
* |new.GetName() == name
|
||||
* @throws IllegalNameException
|
||||
* the given name is not a valid name for any worm
|
||||
* |! isValidName(name)
|
||||
*/
|
||||
public void setName(String name) throws IllegalNameException {
|
||||
|
||||
int validName = isValidName(name);
|
||||
if (validName != -1)
|
||||
throw new IllegalNameException(validName, name);
|
||||
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* check whether the given name is a valid name for all worms
|
||||
*
|
||||
@@ -464,16 +446,36 @@ public class Worm {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the name of the worm tot the given name
|
||||
*
|
||||
* @param name
|
||||
* the new name for the worm
|
||||
* @post the new name of the worm is equal to the given name
|
||||
* |new.GetName() == name
|
||||
* @throws IllegalNameException
|
||||
* the given name is not a valid name for any worm
|
||||
* |! isValidName(name)
|
||||
*/
|
||||
public void setName(String name) throws IllegalNameException {
|
||||
|
||||
int validName = isValidName(name);
|
||||
if (validName != -1)
|
||||
throw new IllegalNameException(validName, name);
|
||||
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* this variable contains the name of the worm
|
||||
*/
|
||||
private String name;
|
||||
|
||||
|
||||
//===================================================================================
|
||||
// endregion
|
||||
|
||||
|
||||
|
||||
// region move
|
||||
//===================================================================================
|
||||
|
||||
@@ -551,7 +553,7 @@ public class Worm {
|
||||
/**
|
||||
*
|
||||
* @param angle
|
||||
* @return
|
||||
* @return ...
|
||||
*/
|
||||
private boolean canTurn(double angle) {
|
||||
return 0 <= angle && angle < (2 * PI) &&
|
||||
@@ -596,17 +598,6 @@ public class Worm {
|
||||
this.actionPoints = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a boolean whether the worm can jump or not
|
||||
*
|
||||
* @return True if and only if the action actionPoints is bigger then 0 and the orientation
|
||||
* is lower then pi
|
||||
* |result == this.actionPoints > 0 && this.orientation < Math.PI
|
||||
*/
|
||||
private boolean canJump() {
|
||||
return this.actionPoints > 0 && this.orientation < PI;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the time the worm will jump
|
||||
*
|
||||
@@ -635,6 +626,17 @@ public class Worm {
|
||||
this.location.item2 + this.jumpVelocity() * sin(this.orientation) * deltaTime - 0.5 * G * pow(deltaTime, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a boolean whether the worm can jump or not
|
||||
*
|
||||
* @return True if and only if the action actionPoints is bigger then 0 and the orientation
|
||||
* is lower then pi
|
||||
* |result == this.actionPoints > 0 && this.orientation < Math.PI
|
||||
*/
|
||||
private boolean canJump() {
|
||||
return this.actionPoints > 0 && this.orientation < PI;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the distance the worm will jump
|
||||
*
|
||||
|
Reference in New Issue
Block a user