small changes
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
kan veranderen tijdens uitvoering
|
||||
defensief
|
||||
|
||||
### massa
|
||||
### massa - DONE?
|
||||
afh. van radius
|
||||
in kg
|
||||
p = 1062 kg/m3
|
||||
@@ -72,7 +72,7 @@
|
||||
type niet gezegd -> double (radius, coordinaat)
|
||||
Double.NEGATIVE_INFINITY && Double.POSITIVE_INFINITY toegestaan
|
||||
|
||||
### Turning and Moving
|
||||
##Turning and Moving
|
||||
|
||||
### method move
|
||||
change location worm (location, orientation, number of steps)
|
||||
@@ -94,7 +94,7 @@
|
||||
total cost step: abs(cos theta) + abs(4sin theta)
|
||||
action point: int (round to next int)
|
||||
|
||||
### Jumping
|
||||
## Jumping
|
||||
|
||||
### method jump
|
||||
change location (respect orientation and action points)
|
||||
@@ -117,7 +117,7 @@
|
||||
jumping: consumes all remaining action points
|
||||
jumpTime and jumpStep must not change attributes of a worm
|
||||
|
||||
### Opmerkingen
|
||||
## Opmerkingen
|
||||
|
||||
future: involve further trajectory parameters or geographical features
|
||||
|
||||
|
@@ -13,7 +13,6 @@ public class Worm {
|
||||
private double minRadius;
|
||||
// mass
|
||||
private double mass;
|
||||
private final int rho = 1062;
|
||||
|
||||
// points
|
||||
private int points;
|
||||
@@ -104,6 +103,9 @@ public class Worm {
|
||||
}
|
||||
|
||||
public void setRadius(double radius) {
|
||||
if (radius < this.minRadius) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
this.radius = radius;
|
||||
setMass(radius);
|
||||
}
|
||||
@@ -122,7 +124,8 @@ public class Worm {
|
||||
|
||||
private void setMass(double radius) {
|
||||
|
||||
double mass = this.rho * (4 / 3 * Math.PI * Math.pow(radius, 3));
|
||||
final int rho = 1062;
|
||||
double mass = rho * (4 / 3 * Math.PI * Math.pow(radius, 3));
|
||||
|
||||
this.mass = mass;
|
||||
setMaxPoints(mass);
|
||||
@@ -133,6 +136,11 @@ public class Worm {
|
||||
}
|
||||
|
||||
public void setPoints(int points) {
|
||||
if (points > this.maxPoints) {
|
||||
points = this.maxPoints;
|
||||
}
|
||||
else if (points < 0)
|
||||
points = 0;
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
@@ -141,5 +149,6 @@ public class Worm {
|
||||
}
|
||||
private void setMaxPoints(double maxPoints) {
|
||||
this.maxPoints = (int) Math.round(maxPoints);
|
||||
setPoints(this.points);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user