-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathTeslaCar.java
44 lines (33 loc) · 1.11 KB
/
TeslaCar.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* This program demonstrate Concrete SubClasses of Car Abstract Class.
* @version 1.01- 17-08-2018
* @author Abhey Rana
*/
import java.util.Calendar;
import java.util.Date;
class TeslaCar extends Car implements Repairable{
public TeslaCar(String modelName, int passengerCapacity, double topSpeed){
super(modelName, passengerCapacity, topSpeed);
}
// Overriding Abstract methods
public void accelerate(){
System.out.println("Tesla's specialized acceleration system");
}
public void brake(){
System.out.println("Tesla's specialized braking system");
}
public String getDescription(){
return "Tesla Car, Model Name: " + this.getModelName() + ", Top Speed: " + this.getTopSpeed();
}
// Overriding abstract methods of Repairable interface.
public boolean isRepairable(){
// Tesla Car has a warranty time and can be repaired during that time only ....
Date currentDate = Calendar.getInstance().getTime();
if(currentDate.getTime() - this.getManufacturingDate().getTime() > 100000)
return false;
return true;
}
public void repair(){
System.out.println("Procedure for repairing Tesla Car");
}
}