From 6a33cab348605297b80b05a17292380cf2fd4d72 Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Wed, 7 Mar 2018 19:12:06 +0100 Subject: [PATCH] commentaar ivm methodes over shape --- OGP1718-Worms/src/Worm.java | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/OGP1718-Worms/src/Worm.java b/OGP1718-Worms/src/Worm.java index ae80ed8..144ea1c 100644 --- a/OGP1718-Worms/src/Worm.java +++ b/OGP1718-Worms/src/Worm.java @@ -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;