Initial commit: advanced OOP workshop project
This commit is contained in:
@@ -22,10 +22,37 @@ 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 void addMileage(double km) {
|
||||
|
||||
if (km < 0)
|
||||
System.out.println("This amount is not acceptable.");
|
||||
else {
|
||||
mileage += km;
|
||||
System.out.println("mileage increased");
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Declare abstract method getEnergyType()
|
||||
|
||||
public void basicInfo() {
|
||||
@@ -37,4 +64,5 @@ public abstract class Vehicle {
|
||||
}
|
||||
|
||||
public abstract void showDetails();
|
||||
public abstract String getEnergyType();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user