Completed tasks and everything but no menu implemented. #1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user