feat: add abstract Vehicle base class

This commit is contained in:
2026-04-24 21:31:56 +03:30
parent 893c779c28
commit b208cf62d4
@@ -0,0 +1,38 @@
package org.example.model;
/*
* Abstract base class for all vehicles.
* This class DOES NOT implement Serviceable.
* Service behavior will be defined in concrete subclasses.
*/
public abstract class Vehicle {
private String brand;
private String model;
private int year;
private double mileage;
public Vehicle(String brand, String model, int year, double mileage) {
this.brand = brand;
this.model = model;
this.year = year;
this.mileage = mileage;
}
// TODO: Create getters for all fields
// TODO: Implement addMileage(double km)
// If km is negative → print error
// Otherwise increase mileage
// TODO: Declare abstract method getEnergyType()
public void basicInfo() {
System.out.println(
year + " " + brand + " " + model +
" | Mileage: " + mileage +
" | Energy: " + getEnergyType()
);
}
}