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