-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMovingVan.java
More file actions
36 lines (29 loc) · 1010 Bytes
/
Copy pathMovingVan.java
File metadata and controls
36 lines (29 loc) · 1010 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
33
34
35
36
public class MovingVan extends Truck {
private int distanceToCargo;
private boolean hasRamp;
public MovingVan(String make, String model, int year, int numWheels,
int distance, boolean rampPresent) {
super(make, model, year, numWheels);
if(distance <= 0) {
throw new IllegalArgumentException();
}
this.distanceToCargo = distance;
this.hasRamp = rampPresent;
}
public int getDistanceToCargo() {
return this.distanceToCargo;
}
public boolean hasRamp() {
return this.hasRamp;
}
public String toString() {
String str = "capacity = " + this.getCapacity();
str = str + ", distance to cargo = " + this.distanceToCargo + ", ";
if(this.hasRamp) {
str = str + "has a ramp";
} else {
str = str + "does not have a ramp";
}
return str;
}
}