feat: add ElectricCar with battery system
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
package org.example.model;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ElectricCar extends Car.
|
||||||
|
* It already inherits Serviceable from Car.
|
||||||
|
*
|
||||||
|
* Service logic for ElectricCar:
|
||||||
|
* - needsService(): return true if mileage > 8000
|
||||||
|
* - performService():
|
||||||
|
* Print "Battery system checked"
|
||||||
|
* Reset chargeLevel to 100
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ElectricCar extends Car {
|
||||||
|
|
||||||
|
private int batteryCapacity;
|
||||||
|
private double chargeLevel;
|
||||||
|
|
||||||
|
public ElectricCar(String brand, String model, int year,
|
||||||
|
double mileage, int seats,
|
||||||
|
int batteryCapacity, double chargeLevel) {
|
||||||
|
|
||||||
|
super(brand, model, year, mileage, seats);
|
||||||
|
this.batteryCapacity = batteryCapacity;
|
||||||
|
this.chargeLevel = chargeLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Override getEnergyType() → return "Electric"
|
||||||
|
|
||||||
|
// TODO: Override showDetails()
|
||||||
|
|
||||||
|
// TODO: Implement charge(double amount)
|
||||||
|
// Validate negative
|
||||||
|
// Cap at 100
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user