some changes to worm

This commit is contained in:
2018-02-26 17:57:37 +01:00
parent 517168ef49
commit 8088bfece9

View File

@@ -13,9 +13,11 @@ public class Worm {
private double minRadius;
// mass
private double mass;
private final int rho = 1062;
// points
private double points;
private int points;
private int maxPoints;
// name
private final String name;
@@ -103,6 +105,7 @@ public class Worm {
public void setRadius(double radius) {
this.radius = radius;
setMass(radius);
}
public double getMinRadius() {
@@ -117,19 +120,26 @@ public class Worm {
return this.mass;
}
public void setMass(double mass) {
private void setMass(double radius) {
double mass = this.rho * (4 / 3 * Math.PI * Math.pow(radius, 3));
this.mass = mass;
setMaxPoints(mass);
}
public double getPoints() {
public int getPoints() {
return this.points;
}
public void setPoints(double points) {
public void setPoints(int points) {
this.points = points;
}
public String getName() {
return this.name;
}
private void setMaxPoints(double maxPoints) {
this.maxPoints = (int) Math.round(maxPoints);
}
}