-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCLkw.java
More file actions
59 lines (46 loc) · 1.47 KB
/
CLkw.java
File metadata and controls
59 lines (46 loc) · 1.47 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
public class CLkw extends CAuto implements IFahrzeug {
private final int mMaxLoad;
private int mCurrentLoad = 0;
public CLkw() {
this("blau", "MAN", 100, 6, 500, 20000);
}
public CLkw(final String color, final String brand, final int maxSpeed, final int gears, int performance, int maxLoad) {
super(color, brand, maxSpeed, gears, performance);
mMaxLoad = maxLoad;
}
public int getMaxLoad() {
return mMaxLoad;
}
public void setLoad(final int load) {
if (load >= 0 && load <= mMaxLoad)
mCurrentLoad = load;
System.out.println("Changed load to " + mCurrentLoad + "kg");
}
public int getCurrentLoad() {
return mCurrentLoad;
}
@Override
public void shiftGears(final int gear) {
super.shiftGears(gear);
}
@Override
public void accelerate(final int increment) {
super.accelerate(increment);
}
@Override
public void brake(final int decrement) {
accelerate(-1 * decrement);
}
@Override
public String toString() {
String s = this.getClass().getName();
s += " : " + this.hashCode();
s += "\nTop speed: " + getMaxSpeed();
s += "\nCurrent speed: " + getCurrentSpeed();
s += "\nGears: " + getGears();
s += "\nCurrentGear: " + getCurrentGear();
s += "\nMaximum load: " + mMaxLoad;
s += "\nCurrent load: " + mCurrentLoad;
return s;
}
}