41 lines
1010 B
Java
41 lines
1010 B
Java
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()
|
|
);
|
|
}
|
|
|
|
public abstract void showDetails();
|
|
}
|