feat: add Chargeable and Refuelable interfaces
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package org.example.behavior;
|
||||
|
||||
public interface Chargeable {
|
||||
void charge(double amount);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package org.example.behavior;
|
||||
|
||||
public interface Refuelable {
|
||||
void refuel(double amount);
|
||||
}
|
||||
@@ -11,7 +11,9 @@ package org.example.model;
|
||||
* Reset chargeLevel to 100
|
||||
*/
|
||||
|
||||
public class ElectricCar extends Car {
|
||||
import org.example.behavior.Chargeable;
|
||||
|
||||
public class ElectricCar extends Car implements Chargeable {
|
||||
|
||||
private int batteryCapacity;
|
||||
private double chargeLevel;
|
||||
|
||||
@@ -11,7 +11,9 @@ package org.example.model;
|
||||
* Reset fuelLevel to 100
|
||||
*/
|
||||
|
||||
public class GasCar extends Car {
|
||||
import org.example.behavior.Refuelable;
|
||||
|
||||
public class GasCar extends Car implements Refuelable {
|
||||
|
||||
private double fuelLevel;
|
||||
private String fuelType;
|
||||
|
||||
Reference in New Issue
Block a user