forked from oopd-gu-chalmers/lab1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSaab95.java
37 lines (30 loc) · 923 Bytes
/
Saab95.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.awt.*;
public class Saab95 extends Car {
private boolean turboOn;
public Saab95(){
super(2,125, Color.red, "Saab95");
// använder super för att få tillgång till car konstruktionen för att slippa göra egna variabler
turboOn = false;
stopEngine();
}
public boolean getTurbo() { return turboOn;}
public void setTurboOn(){
turboOn = true;
}
public void setTurboOff(){
turboOn = false;
}
private double speedFactor(){
double turbo = 1;
if(turboOn) turbo = 1.3;
return getEnginePower() * 0.01 * turbo;
}
@Override
protected void incrementSpeed(double amount){
this.setCurrentSpeed(getCurrentSpeed() + speedFactor() * amount);
}
@Override
protected void decrementSpeed(double amount){
this.setCurrentSpeed(getCurrentSpeed() - speedFactor() * amount);
}
}