Initial commit: advanced OOP workshop project

This commit is contained in:
2026-04-28 11:23:09 -07:00
parent 6cb8f9a8d8
commit d76daf2454
8 changed files with 277 additions and 85 deletions
+28
View File
@@ -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();
}