diff --git a/src/main/java/org/model/ElectricCar.java b/src/main/java/org/model/ElectricCar.java index 2ee9bd8..840edef 100644 --- a/src/main/java/org/model/ElectricCar.java +++ b/src/main/java/org/model/ElectricCar.java @@ -26,13 +26,36 @@ public class ElectricCar extends Car implements Chargeable { this.batteryCapacity = batteryCapacity; this.chargeLevel = chargeLevel; } - + public boolean needsService(Vehicle v) { + return v.getMileage() > 8000; + } + public void performService() { + System.out.println("Battery system checked"); + this.chargeLevel = 100; + } + @Override + public String getEnergyType() { + return "Electric"; + } // TODO: Override getEnergyType() → return "Electric" + @Override + public void showDetails() { + super.showDetails(); + System.out.println("Battery capacity: " + this.batteryCapacity + ", Charge level: " + + this.chargeLevel); + } // TODO: Override showDetails() // Call super.showDetails() // Print battery capacity and charge level + public void charge(double amount) { + if (amount > 0 && this.chargeLevel + amount <= 100) { + this.chargeLevel += amount; + } else if (amount > 0 && this.chargeLevel + amount > 100) { + this.chargeLevel = 100; //if input amount causes the battery to charge pass 100%, we set it to 100%. + } + } // TODO: Implement charge(double amount) // Validate negative // Cap at 100