-
Notifications
You must be signed in to change notification settings - Fork 3
/
Promotion.java
64 lines (50 loc) · 1.44 KB
/
Promotion.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
package TEST;
import java.util.*;
public class Promotion {
//promotionItem are group of menu items on discounted price or special items not in menue
private ArrayList<MenuItem> promotionSet;
private String promoName;
private double price;
public void addMenuItem(MenuItem mItem) {
promotionSet.add(mItem);
}
public void displayPromotionItems() {
int index = 0;
for(int i = 0; i< promotionSet.size();i++) {
System.out.print("item " + (i + 1) + ": ");
System.out.println(promotionSet.get(i).getItemName());
System.out.println(promotionSet.get(i).getItemPrice());
System.out.println(promotionSet.get(i).getItemDescription());
}
}
public Promotion() {
promotionSet = new ArrayList<>();
}
public void setPromoName(String name) {
this.promoName = name;
}
public void setPromoPrice(double price) {
this.price = price;
}
public String getPromoName() {
return this.promoName;
}
public double getPromoPrice() {
return this.price;
}
public ArrayList<MenuItem> getPromoList(){
return this.promotionSet;
}
public MenuItem getMenuItem(int index) {
//get item from array,array 0 base index
//item display from 1 onwards but start from 0 base index
return promotionSet.get(index);
}
public double getOriginalPrice() {
double sum = 0;
for(MenuItem mItem : promotionSet) {
sum = sum + mItem.getItemPrice();
}
return sum;
}
}