-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMyOwnAutoShop.java
More file actions
57 lines (54 loc) · 1.54 KB
/
MyOwnAutoShop.java
File metadata and controls
57 lines (54 loc) · 1.54 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
abstract class Car{
int speed;
double regularPrice;
String color;
Car (int speed,double regularPrice,String color){
this.speed=speed;
this.regularPrice=regularPrice;
this.color=color;
}
void getSalePrice(){
System.out.println(regularPrice);
}
}
class Truck extends Car{
int weight;
Truck (int speed,double regularPrice,String color,int weight){
super(speed,regularPrice,color);
this.weight=weight;
}
void getSalePrice(){
if (weight>2000){
System.out.println("10% discount:"+(regularPrice*0.1));
} else{
System.out.println("20% Discount:"+(regularPrice*0.2));
}
}
}
class Ford extends Car{
int year;
int manufactureDiscount;
Ford (int speed,double regularPrice,String color,int year,int manufactureDiscount){
super(speed,regularPrice,color);
this.year=year;
this.manufactureDiscount=manufactureDiscount;
}
void getSalePrice(){
super.getSalePrice();
System.out.println(regularPrice-(double) manufactureDiscount);
}
}
class Sedan extends Car{
int length;
Sedan (int speed,double regularPrice,String color,int length){
super(speed,regularPrice,color);
this.length=length;
}
void getSalePrice(){
if (length>20){
System.out.println("5% discount:"+(regularPrice*0.05));
}else{
System.out.println("10% discount:"+(regularPrice*0.1));
}
}
}