implement todo tasks in Car.java
This commit is contained in:
@@ -17,16 +17,29 @@ public abstract class Car extends Vehicle implements Serviceable {
|
||||
|
||||
public Car(String brand, String model, int year,
|
||||
double mileage, int seats) {
|
||||
|
||||
super(brand, model, year, mileage);
|
||||
// TODO: Call super constructor
|
||||
this.seats = seats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEnergyType() {
|
||||
return "Unknown";
|
||||
}
|
||||
// TODO: Override getEnergyType() → return "Unknown"
|
||||
|
||||
@Override
|
||||
public void showDetails() {
|
||||
System.out.println("Car details: brand: " + this.getBrand() + ", model: "
|
||||
+ this.getModel() + ", year: " + this.getYear() + ", mileage: "
|
||||
+ this.getMileage() + ", number of seats: " + this.seats);
|
||||
}
|
||||
// TODO: Override showDetails()
|
||||
// Print brand, model, year, mileage, and number of seats
|
||||
|
||||
public Boolean needService(Vehicle v) {
|
||||
return v.getMileage() > 10000;
|
||||
}
|
||||
/*
|
||||
* Implement Serviceable methods:
|
||||
*
|
||||
@@ -34,8 +47,11 @@ public abstract class Car extends Vehicle implements Serviceable {
|
||||
* - Check the mileage of the current car
|
||||
* - If mileage > 10000 return true
|
||||
* - Otherwise return false
|
||||
*
|
||||
* performService():
|
||||
*/
|
||||
public void performService() {
|
||||
System.out.println("General car service completed");
|
||||
}
|
||||
/* performService():
|
||||
* - Print: "General car service completed"
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user