-
Notifications
You must be signed in to change notification settings - Fork 0
/
Smoothie.java
75 lines (57 loc) · 1.75 KB
/
Smoothie.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
public class Smoothie extends Beverage{
private int numOfFruits;
private boolean addProtein;
private final double FRUIT_COST = .5;
private final double PROTEIN_COST = 1.5;
public Smoothie(String n, SIZE s, int nof, boolean ap) {
super(n, TYPE.SMOOTHIE, s);
numOfFruits = nof;
addProtein = ap;
}
public String toString() {
String s = getBevName() +", " +getSize() +" " +numOfFruits +" Fruits";
if (addProtein) { s += " Protein powder"; }
s += ", $" +calcPrice();
return s;
}
public boolean equals(Smoothie s) {
if (super.equals(s) && numOfFruits==s.getNumOfFruits() && addProtein==s.getAddProtien()) {
return true;
}
else {
return false;
}
}
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();
}
price += numOfFruits * FRUIT_COST;
if (addProtein) {
price += PROTEIN_COST;
}
return price;
}
public double getFruitCost() {
return FRUIT_COST;
}
public double getProteinCost() {
return PROTEIN_COST;
}
public int getNumOfFruits() {
return numOfFruits;
}
public boolean getAddProtien() {
return addProtein;
}
public void setNumOfFruits(int nof) {
numOfFruits = nof;
}
public void setProteinPowder(boolean ap) {
addProtein = ap;
}
}