-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOutlander.java
More file actions
30 lines (26 loc) · 782 Bytes
/
Outlander.java
File metadata and controls
30 lines (26 loc) · 782 Bytes
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
public class Outlander extends car1 {
private int roadserviceMonths;
public Outlander( int roadserviceMonths) {
super("Outlander", "4WD", 5, 5, 6, false);
this.roadserviceMonths = roadserviceMonths;
}
public void accelerate(int rate){
int newVelocity=getCurrentVelocity()+rate;
if (newVelocity==0){
stop();
changeGears(1);
}
else if(newVelocity>0&&newVelocity<=10){
changeGears(1);
}
else if(newVelocity>10&&newVelocity<=20) {
changeGears(2);
}
else if(newVelocity>20&&newVelocity<=30) {
changeGears(4);
}
if(newVelocity>0){
changeVelocity(newVelocity,getCurrentDirection());
}
}
}