-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuyPetrol.java
More file actions
56 lines (48 loc) · 1.66 KB
/
BuyPetrol.java
File metadata and controls
56 lines (48 loc) · 1.66 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
package Chapter2;
public class BuyPetrol {
private String stationLocation;
private String petrolType;
private int quantity;
private double price;
private double percentageDiscount;
public BuyPetrol(String stationLocation, int petrolType, int quantity, double price, double percentageDiscount) {
this.stationLocation = stationLocation;
this.petrolType = String.valueOf(petrolType);
this.quantity = quantity;
this.price = price;
this.percentageDiscount = percentageDiscount;
}
public void setStationLocation(String stationLocation) {
this.stationLocation = stationLocation;
}
public String getStationLocation() {
return stationLocation;
}
public void setPetrolType(String petrolType) {
this.petrolType = petrolType;
}
public String getPetrolType() {
return petrolType;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public int getQuantity() {
return quantity;
}
public void setPrice(double price) {
this.price = price;
}
public double getPrice() {
return price;
}
public void setPercentageDiscount(double percentageDiscount) {
this.percentageDiscount = percentageDiscount;
}
public double getPercentageDiscount() {
return percentageDiscount;
}
public double getPurchaseAmount() {
return quantity * price * (1 - percentageDiscount / 100);
}
}