-
Notifications
You must be signed in to change notification settings - Fork 0
/
Alcohol.java
53 lines (45 loc) · 1.54 KB
/
Alcohol.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
45
46
47
48
49
50
51
52
53
public class Alcohol extends Beverage{
private final double WEEKEND_FEE = .6;
private boolean isWeekend;
public Alcohol(String n, SIZE s, boolean iw) {
super(n, TYPE.ALCOHOL, s);
isWeekend = iw;
}
public String toString() {
String s = getBevName() +", " +getSize();
if (isWeekend) {
s += " Weekend";
}
s += ",$" +calcPrice();
return s;
}
public boolean equals(Alcohol a) {
if (super.equals(a) && isWeekend == a.getIsWeekend()) {
return true;
}
else {
return false;
}
}
public boolean getIsWeekend() {
return isWeekend;
}
public double getWeekendFee() {
return WEEKEND_FEE;
}
public void setIsWeekend(boolean is) {
isWeekend = is;
}
public double calcPrice() {
double price = super.getBasePrice();
if (super.getSize() == SIZE.MEDIUM) {
price += super.getSizePrice();
}
else if (super.getSize() == SIZE.LARGE) {
price += 2 * super.getSizePrice();
}
if (isWeekend) {
price += WEEKEND_FEE;
}
return price;
}}