forked from Denisolt/CSCI-160
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMasterOrder.java
More file actions
60 lines (56 loc) · 1.64 KB
/
MasterOrder.java
File metadata and controls
60 lines (56 loc) · 1.64 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
/*
Denisolt Shakhbulatov
18.11.2015
_______________________________________
+ MasterOrder +
+_____________________________________+
+ -orders:ArrayList<CookieOrder> +
+_____________________________________+
+ +MasterOrder() +
++addOrder(theOrder:CookieOrder):void +
+ +getTotalBoxes():int +
++removeVariety(cookieVar:String):void+
+ +showOrders():void +
+_____________________________________+
*
*/
import java.util.ArrayList;
public class MasterOrder
{
private ArrayList<CookieOrder>orders;
public MasterOrder()
{
orders = new ArrayList<CookieOrder>();
}
public void addOrder(CookieOrder input)
{
orders.add(input);
}
public int getTotalBoxes()
{
int boxes = 0;
for (CookieOrder order : orders)
boxes = boxes + order.getNumBoxes();
return boxes;
}
public int removeVariety(String input)
{
int count =0;
for (int index = 0; index < orders.size(); index++)
{
if (input.equalsIgnoreCase(orders.get(index).getVariety()))
{
count = count + orders.get(index).getNumBoxes();
orders.remove(index).getVariety();
}
}
System.out.println(count + " were removed.");
return count;
}
public void showOrders()
{
for(int index = 0; index<orders.size(); index++)
System.out.println(orders.get(index).getVariety() + " " + orders.get(index).getNumBoxes());
System.out.println("There are " + getTotalBoxes() + " boxes of cookies in total.");
}
}