-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCar.java
More file actions
46 lines (36 loc) · 970 Bytes
/
Car.java
File metadata and controls
46 lines (36 loc) · 970 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
41
42
43
44
45
package Chapter2;
public class Car {
private String model;
private String year;
private double price;
public Car(String model, String year, double price){
this.model =model;
this.year = year;
if(price > 0.0){
this.price = price;
}
}
public void setModel(String model){
this.model = model;
}
public String getModel(){
return model;
}
public void setYear(String year){
this.year = year;
}
public String getYear(){
return year;
}
public void setPrice(double price){
if(price > 0){
this.price = price;
}
}
public double getPrice(){
return price;
}
public void setDiscount(double discount){
price = price - (discount/100*price);
}
}