-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathTruck.java
More file actions
32 lines (26 loc) · 803 Bytes
/
Truck.java
File metadata and controls
32 lines (26 loc) · 803 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
31
32
public class Truck extends Vehicle {
private final int cargo;
private boolean isTransformed;
public Truck(String make, String model, Engine engine, int cargo) {
super(make, model, engine);
this.cargo = cargo;
}
public int getCargo() {
return cargo;
}
public boolean isTransformed() {
return isTransformed;
}
public void transform() {
if (isTransformed) {
System.out.println(
getMake() + " " + getModel() + " verwandelt sich in einen Lastwagen zurueck");
} else {
System.out.println(getMake() + " " + getModel() + " verwandelt sich in einen Autobot");
}
isTransformed = !isTransformed;
}
public String toString() {
return getMake() + " " + getModel() + " (" + getEngine().getDescription() + ", " + cargo + "t)";
}
}