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,
|
public Car(String brand, String model, int year,
|
||||||
double mileage, int seats) {
|
double mileage, int seats) {
|
||||||
|
super(brand, model, year, mileage);
|
||||||
// TODO: Call super constructor
|
// TODO: Call super constructor
|
||||||
this.seats = seats;
|
this.seats = seats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEnergyType() {
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
// TODO: Override 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()
|
// TODO: Override showDetails()
|
||||||
// Print brand, model, year, mileage, and number of seats
|
// Print brand, model, year, mileage, and number of seats
|
||||||
|
|
||||||
|
public Boolean needService(Vehicle v) {
|
||||||
|
return v.getMileage() > 10000;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Implement Serviceable methods:
|
* Implement Serviceable methods:
|
||||||
*
|
*
|
||||||
@@ -34,8 +47,11 @@ public abstract class Car extends Vehicle implements Serviceable {
|
|||||||
* - Check the mileage of the current car
|
* - Check the mileage of the current car
|
||||||
* - If mileage > 10000 return true
|
* - If mileage > 10000 return true
|
||||||
* - Otherwise return false
|
* - Otherwise return false
|
||||||
*
|
*/
|
||||||
* performService():
|
public void performService() {
|
||||||
|
System.out.println("General car service completed");
|
||||||
|
}
|
||||||
|
/* performService():
|
||||||
* - Print: "General car service completed"
|
* - Print: "General car service completed"
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user