Complete project with HybridCar bonus
This commit is contained in:
@@ -1,14 +1,5 @@
|
||||
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;
|
||||
@@ -24,7 +15,26 @@ public class SportsCar extends GasCar {
|
||||
this.zeroToHundred = zeroToHundred;
|
||||
}
|
||||
|
||||
// TODO: Override showDetails()
|
||||
// Call super.showDetails()
|
||||
// Print acceleration time
|
||||
@Override
|
||||
public boolean needsService(Vehicle v) {
|
||||
if (v.getMileage()> 5000){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performService() {
|
||||
super.performService();
|
||||
System.out.println("High-performance brake system checked");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showDetails() {
|
||||
super.showDetails();
|
||||
System.out.println(" | Acceleration time (0-100): " + zeroToHundred + " seconds");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user