feat: implement GasCar fuel logic
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
package org.example.model;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GasCar extends Car.
|
||||||
|
* Inherits Serviceable from Car.
|
||||||
|
*
|
||||||
|
* Service logic for GasCar:
|
||||||
|
* - needsService(): return true if mileage > 12000
|
||||||
|
* - performService():
|
||||||
|
* Print "Engine oil changed"
|
||||||
|
* Reset fuelLevel to 100
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class GasCar extends Car {
|
||||||
|
|
||||||
|
private double fuelLevel;
|
||||||
|
private String fuelType;
|
||||||
|
|
||||||
|
public GasCar(String brand, String model, int year,
|
||||||
|
double mileage, int seats,
|
||||||
|
double fuelLevel, String fuelType) {
|
||||||
|
|
||||||
|
super(brand, model, year, mileage, seats);
|
||||||
|
this.fuelLevel = fuelLevel;
|
||||||
|
this.fuelType = fuelType;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Override getEnergyType() → return fuelType + " (Gas)"
|
||||||
|
|
||||||
|
// TODO: Implement refuel(double amount)
|
||||||
|
// Validate amount
|
||||||
|
// Cap at 100
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user