46 lines
1.1 KiB
Java
46 lines
1.1 KiB
Java
package org.model;
|
|
|
|
/*
|
|
* SportsCar extends GasCar.
|
|
*
|
|
* Special service logic for SportsCar:
|
|
* - needsService(): return true if mileage > 5000
|
|
* - performService():
|
|
* Print "High-performance brake system checked"
|
|
*/
|
|
|
|
public class SportsCar extends GasCar {
|
|
|
|
private double zeroToHundred;
|
|
|
|
public SportsCar(String brand, String model, int year,
|
|
double mileage, int seats,
|
|
double fuelLevel, String fuelType,
|
|
double zeroToHundred) {
|
|
|
|
super(brand, model, year, mileage, seats,
|
|
fuelLevel, fuelType);
|
|
|
|
this.zeroToHundred = zeroToHundred;
|
|
}
|
|
|
|
public boolean needsService(Vehicle v){
|
|
if(v.getMileage() > 5000) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public void performService(){
|
|
System.out.println( "High-performance brake system checked");
|
|
}
|
|
|
|
|
|
public void showDetails(){
|
|
super.showDetails();
|
|
System.out.println("| acceleration :" + this.zeroToHundred);
|
|
}
|
|
// Call super.showDetails()
|
|
// Print acceleration time
|
|
}
|