-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtilityVehicle.java
More file actions
33 lines (23 loc) · 884 Bytes
/
Copy pathUtilityVehicle.java
File metadata and controls
33 lines (23 loc) · 884 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
public class UtilityVehicle extends Car {
private boolean fourWheelDrive; // Class field
public UtilityVehicle(String vinNumber, String make, String model, int mileage, boolean fourWheelDrive) {
super(vinNumber, make, model, mileage);
this.fourWheelDrive = fourWheelDrive; // Initialize from parameter
}
public boolean isFourWheelDrive() {
return fourWheelDrive;
}
public void setFourWheelDrive(boolean fourWheelDrive) {
this.fourWheelDrive = fourWheelDrive;
}
@Override
public String toString() {
String stringOriginal = super.toString();
return "Utility vehicle, " + stringOriginal + ", Has four wheel drive: " + fourWheelDrive;
}
@Override
public String getInfo() {
String stringGetinfo = super.toString();
return "Utility vehicle: " + stringGetinfo;
}
}