Documentatie Rifle

This commit is contained in:
Leen Dereu
2018-05-23 22:22:16 +02:00
parent 7f82c3e334
commit 9f8a250f71

View File

@@ -9,25 +9,52 @@ import static java.lang.Math.sin;
public class Rifle extends Projectile { public class Rifle extends Projectile {
/**
* @param worm
*
* @post ...
* |worm == worm
* @post ...
* |new.getMass() == 10
* @post ...
* |new.getForce() == 1.5
*/
public Rifle(Worm worm) { public Rifle(Worm worm) {
super(worm, 10, 1.5); super(worm, 10, 1.5);
} }
/**
* @return ...
* |result == ThreadLocalRandom.current().nextInt(1,6) * 2
*/
@Override @Override
protected int getRandomHitPoints() { protected int getRandomHitPoints() {
return ThreadLocalRandom.current().nextInt(1,6) * 2; return ThreadLocalRandom.current().nextInt(1,6) * 2;
} }
/**
* @return ...
* |result == this.hitPoints
*/
@Override @Override
protected int getImpactHitPoints() { protected int getImpactHitPoints() {
return this.hitPoints; return this.hitPoints;
} }
/**
* @param value
*
* @post ...
* |if (value > 10)
* | value = 10
* |else if (value % 2 != 0)
* | value--
* |super.hitPoints = value
*/
@Override @Override
protected void setHitPoints(int value) { protected void setHitPoints(int value) {
if (value > 10) value = 10; if (value > 10) value = 10;
else if (value % 2 != 0) value--; else if (value % 2 != 0) value--;
super.hitPoints = value; super.hitPoints = value;
} }
} }