Complete the class Car
This commit is contained in:
@@ -15,18 +15,30 @@ public abstract class Car extends Vehicle implements Serviceable {
|
||||
|
||||
private int seats;
|
||||
|
||||
public Car(String brand, String model, int year,
|
||||
double mileage, int seats) {
|
||||
public Car(String brand, String model, int year, double mileage, int seats) {
|
||||
|
||||
// TODO: Call super constructor
|
||||
super(brand, model, year, mileage);
|
||||
this.seats = seats;
|
||||
}
|
||||
|
||||
// TODO: Override getEnergyType() → return "Unknown"
|
||||
@Override
|
||||
public String getEnergyType() { return "Unknown"; }
|
||||
|
||||
// TODO: Override showDetails()
|
||||
// Print brand, model, year, mileage, and number of seats
|
||||
|
||||
@Override
|
||||
public void showDetails()
|
||||
{
|
||||
System.out.println("==========================");
|
||||
System.out.println("Brand : " + getBrand());
|
||||
System.out.println("Model : " + getModel());
|
||||
System.out.println("Year : " + getYear());
|
||||
System.out.println("Mileage : " + getMileage());
|
||||
System.out.println("Number of seats : " + seats);
|
||||
System.out.println("==========================");
|
||||
}
|
||||
/*
|
||||
* Implement Serviceable methods:
|
||||
*
|
||||
@@ -38,4 +50,15 @@ public abstract class Car extends Vehicle implements Serviceable {
|
||||
* performService():
|
||||
* - Print: "General car service completed"
|
||||
*/
|
||||
public boolean needService(Vehicle v)
|
||||
{
|
||||
if (getMileage() > 1000 ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performService()
|
||||
{
|
||||
System.out.println("Gneral car service completed");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user