-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSellingCars.java
More file actions
41 lines (40 loc) · 827 Bytes
/
SellingCars.java
File metadata and controls
41 lines (40 loc) · 827 Bytes
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
class Car{
int speed;
double regprice;
String color;
Car(String color,int speed,double regprice){
this.color=color;
this.regprice=regprice;
this.speed=speed;
}
double getSalePrice(){
return regprice;
}
}
class Truck extends Car{
int weight;
int discount;
Truck(String color,int speed,double regprice,int weight){
super(color,speed,regprice);
this.weight=weight;
if(weight>2000) discount=10;
else discount=20;
}
double getSalePrice(){
return super.getSalePrices()-dicount*regprice/100 ;
}
}
class Ford extends Car{
int year;
int mdisc;
Ford(String color,int speed,double regprice,int year,int mdisc){
super(color,speed,regprice);
this.year=year;
this.mdisc=mdisc;
}
double getSalePrice(){
return regprice-mdisc;
}
}
public class SellingCar{
public static void main(String args[]){