commentaar ivm methodes over shape
This commit is contained in:
@@ -184,7 +184,9 @@ public class Worm {
|
||||
//===================================================================================
|
||||
|
||||
/**
|
||||
* @return the radius of the worm
|
||||
* Return the radius of the worm
|
||||
* the radius of the worm expresses half of the
|
||||
* width of the worm
|
||||
*/
|
||||
@Basic
|
||||
public double getRadius() {
|
||||
@@ -192,9 +194,15 @@ public class Worm {
|
||||
}
|
||||
|
||||
/**
|
||||
* set the radius of the worm to the given radius
|
||||
*
|
||||
* @param radius
|
||||
* the new radius for the worm
|
||||
* @post the new radius of the worm is equal to the given radius
|
||||
* |new.getRadius() == radius
|
||||
* @throws IllegalArgumentException
|
||||
* the given radius is not a valid radius for any worm
|
||||
* |! isValidRadius(radius)
|
||||
*/
|
||||
public void setRadius(double radius) throws IllegalArgumentException {
|
||||
if (radius < this.minRadius)
|
||||
@@ -204,14 +212,32 @@ public class Worm {
|
||||
setMass(radius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the minimum radius the worm can have
|
||||
* the minimum radius of the worm expresses the minimum length
|
||||
* of half of the width of the worm
|
||||
*/
|
||||
public double getMinRadius() {
|
||||
return this.minRadius;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the mass of the worm
|
||||
* the mass of the worm expresses the weight of the worm
|
||||
*/
|
||||
public double getMass() {
|
||||
return this.mass;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the mass of the worm to the given mass (dependent on the radius)
|
||||
*
|
||||
* @param radius
|
||||
* part of the formula to calculate the mass
|
||||
* @post the new mass of the worm is equal to
|
||||
* rho * (4 / 3 * Math.PI * Math.pow(radius, 3))
|
||||
* |new.getMass() == rho * (4 / 3 * Math.PI * Math.pow(radius, 3))
|
||||
*/
|
||||
private void setMass(double radius) {
|
||||
|
||||
final int rho = 1062;
|
||||
|
Reference in New Issue
Block a user