-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCookieOrder.java
More file actions
58 lines (50 loc) · 1.58 KB
/
CookieOrder.java
File metadata and controls
58 lines (50 loc) · 1.58 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
/**
* Write a description of class CookieOrder here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class CookieOrder
{
// instance variables - replace the example below with your own
private String variety;
private int numBoxes;
/**
* Constructor for objects of class CookieOrder
*/
public CookieOrder(String variety, int numBoxes)
{
// initialise instance variables
this.variety = variety;
this.numBoxes = numBoxes;
}
public String getVariety()
{
return variety;
}
public int getNumBoxes()
{
return numBoxes;
}
public static void main(String[] args)
{
CookieOrder c1 = new CookieOrder("Oatmeal Raisin",30);
CookieOrder c2 = new CookieOrder("Chocolate Chip", 25);
CookieOrder c3 = new CookieOrder("Chocolate Chip", 20);
CookieOrder c4 = new CookieOrder("Double Chocolate", 15);
MasterOrder master = new MasterOrder();
master.addOrder(c1);
master.addOrder(c2);
master.addOrder(c3);
master.addOrder(c4);
int total = master.getTotalBoxes();
System.out.println("total should be 90");
System.out.println("total: " + total);
int removed = master.removeVariety("Chocolate Chip");
System.out.println("removed should be 45");
System.out.println("removed: " + removed);
total = master.getTotalBoxes();
System.out.println("total should be 45");
System.out.println("total: " + total);
}
}