implement project #1
@@ -20,13 +20,38 @@ public abstract class Vehicle {
|
||||
this.mileage = mileage;
|
||||
}
|
||||
|
||||
// TODO: Create getters for all fields
|
||||
|
||||
// TODO: Implement addMileage(double km)
|
||||
public String getBrand() {
|
||||
return this.brand;
|
||||
}
|
||||
|
||||
public String getModel() {
|
||||
return this.model;
|
||||
}
|
||||
|
||||
public int getYear() {
|
||||
return this.year;
|
||||
}
|
||||
|
||||
public double getMileage() {
|
||||
return this.mileage;
|
||||
}
|
||||
|
||||
|
||||
// If km is negative → print error
|
||||
// Otherwise increase mileage
|
||||
public void addMileage(double km) {
|
||||
if(km<0) {
|
||||
System.out.print("km cannot be negative");
|
||||
}
|
||||
else {
|
||||
this.mileage += km;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public abstract String getEnergyType();
|
||||
|
||||
// TODO: Declare abstract method getEnergyType()
|
||||
|
||||
public void basicInfo() {
|
||||
System.out.println(
|
||||
|
||||
Reference in New Issue
Block a user