-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSaab95.java
32 lines (27 loc) · 993 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
import java.awt.*;
/**
* Extends the abstract car class. Saab95 also has a turbo functionallity which will affect its speed factor.
*/
public class Saab95 extends PassengerCar implements Turboable {
private boolean turboOn;
private final static String modelName = VehicleModel.Saab95.name();
Saab95(double enginePower, double currentSpeed, Color color, int nrDoors, double x, double y, Direction direction, int weight) {
super(enginePower, currentSpeed, color, nrDoors, x, y, direction, weight,modelName);
}
public void setTurboOn(){
turboOn = true;
}
public void setTurboOff(){
turboOn = false;
}
/**
* Calculates and return the speed factor. If the turbo is turned it will increase the speed factor.
* @return a double value of the speed factor.
*/
@Override
public double speedFactor(){
double turbo = 1;
if(turboOn) turbo = 2;
return getEnginePower() * 0.01 * turbo;
}
}