forked from Kitch05/Vending-Machine-with-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectPopulator.java
More file actions
165 lines (138 loc) · 4.61 KB
/
Copy pathObjectPopulator.java
File metadata and controls
165 lines (138 loc) · 4.61 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import java.util.ArrayList;
public class ObjectPopulator {
private ArrayList<Money> moneyStored;
private Item[] allSellableItems, patties, addOns, condiments;
/**
* Class constructor
*/
public ObjectPopulator() {
populateMoneyStored();
this.patties = populatePatties();
this.addOns = populateAddOns();
this.condiments = populateCondiments();
this.allSellableItems = populateItemList();
}
/**
* Creates the different denominations and their stack in the machine.
*/
private void populateMoneyStored() {
this.moneyStored = new ArrayList<Money>();
this.moneyStored.add(new Money(1000, 10));
this.moneyStored.add(new Money(500, 20));
this.moneyStored.add(new Money(200, 15));
this.moneyStored.add(new Money(100, 25));
this.moneyStored.add(new Money(50, 30));
this.moneyStored.add(new Money(20, 50));
this.moneyStored.add(new Money(10, 100));
this.moneyStored.add(new Money(5, 5000));
this.moneyStored.add(new Money(1, 5000));
this.moneyStored.add(new Money(0.5, 5000));
this.moneyStored.add(new Money(0.25, 5000));
}
/**
* Creates and stores multiple items under the patty category
* @return an item array
*/
private Item[] populatePatties() {
Item chicken = new ChickenPatty(),
beef = new BeefPatty(),
turkey = new TurkeyPatty(),
veggie = new VeggiePatty(),
wagyu = new WagyuPatty();
Item[] items = {chicken, beef, turkey, veggie, wagyu};
for (Item item : items) {
for (int i = 0; i < 10; i++)
item.addItem();
}
return items;
}
/**
* Creates and stores multiple items under the add-ons category
* @return an item array
*/
private Item[] populateAddOns() {
Item lettuce = new Lettuce(),
onionRings = new OnionRings(),
tomato = new Tomato(),
mushroom = new Mushroom(),
pickles = new Pickles(),
jalapenos = new Jalapenos(),
ham = new Ham(),
egg = new Egg(),
cheese = new Cheese(),
bacon = new Bacon();
Item[] items = {lettuce, onionRings, tomato, mushroom, pickles, jalapenos, ham, egg, cheese, bacon};
for (Item item : items) {
for (int i = 0; i < 10; i++)
item.addItem();
}
return items;
}
/**
* Creates and stores multiple items under the condiments category
* @return an item array
*/
private Item[] populateCondiments() {
Item ketchup = new Ketchup(),
mustard = new Mustard(),
mayo = new Mayo(),
bbq = new BbqSauce(),
siracha = new Siracha();
Item[] items = {ketchup, mayo, mustard, bbq, siracha};
for (Item item : items) {
for (int i = 0; i < 50; i++)
item.addItem();
}
return items;
}
/**
* Stores all items in every category into one array
* @return an item array
*/
private Item[] populateItemList() {
int size = this.patties.length + this.addOns.length + this.condiments.length;
Item[] items = new Item[size];
for (int i = 0; i < patties.length; i++)
items[i] = patties[i];
for (int i = patties.length; i < size - patties.length; i++)
items[i] = addOns[i-patties.length];
for (int index = size - patties.length; index < size; index++)
items[index] = condiments[index - (size - patties.length)];
return items;
}
/**
* Returns the add-ons item array
* @return an item array
*/
public Item[] getAddOns() {
return addOns;
}
/**
* Returns the whole item list array
* @return an item array
*/
public Item[] getItemList() {
return allSellableItems;
}
/**
* Returns the condiments item array
* @return an item array
*/
public Item[] getCondiments() {
return condiments;
}
/**
* Returns the patties item array
* @return an item array
*/
public Item[] getPatties() {
return patties;
}
/**
* Returns the money list
* @return an array list
*/
public ArrayList<Money> getMoneyStored() {
return moneyStored;
}
}