oop-labs-collection/labs/6/RPI.java

29 lines
607 B
Java
Raw Normal View History

public class RPI extends Appliance {
private float power = 15.0f;
private float postBootDecreaseIn = 10.0f;
public RPI(boolean plugged) {
super(plugged);
}
public void step(float seconds, float ventRPM) {
postBootDecreaseIn -= seconds;
if ((postBootDecreaseIn <= 0) && (power >= 5.0)) {
power -= seconds;
}
if (power < 5.0) {
power = 5.0f;
}
}
public float getPowerConsumption() {
if (super.getPowerState()) {
return power;
} else {
return 0f;
}
}
}