WS-03
This commit is contained in:
@@ -21,12 +21,35 @@ public abstract class Vehicle {
|
||||
}
|
||||
|
||||
// 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 double addMileage(double km)
|
||||
{
|
||||
if (km<0)
|
||||
{
|
||||
System.out.println("error");
|
||||
return mileage;
|
||||
}
|
||||
mileage+=km*0.621371;
|
||||
return mileage;
|
||||
}
|
||||
|
||||
// TODO: Declare abstract method getEnergyType()
|
||||
public abstract String getEnergyType();
|
||||
|
||||
public void basicInfo() {
|
||||
System.out.println(
|
||||
@@ -37,4 +60,6 @@ public abstract class Vehicle {
|
||||
}
|
||||
|
||||
public abstract void showDetails();
|
||||
public abstract void performService();
|
||||
public abstract boolean needsService();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user