-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoxUsageDemo.java
More file actions
69 lines (51 loc) · 1.37 KB
/
Copy pathBoxUsageDemo.java
File metadata and controls
69 lines (51 loc) · 1.37 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
/**
* This is a demo of using the SingleItemBox class.
* @author K. Raven Russell
*/
public class BoxUsageDemo {
/**
* This is a main method with demo code.
* @param args command line args (not used)
*/
public static void main(String[] args) {
//demo putting an apple in a box
/**
* Class for apples.
*/
class Apple { }
//make an apple
Apple a1 = new Apple();
//put the apple in a box
SingleItemBox<Apple> appleBox = new SingleItemBox<>(a1);
//check that the apple was put in the box
if(appleBox.getItem().equals(a1)) {
System.out.println("yay 1");
}
//demo putting a banana in a box
/**
* Class for bananas.
*/
class Banana { }
//make a banana
Banana b1 = new Banana();
//put the banana in a box
SingleItemBox<Banana> bananaBox = new SingleItemBox<>(b1);
//check that the banana was put in the box
if(bananaBox.getItem().equals(b1)) {
System.out.println("yay 2");
}
//demo putting a banana in a box
/**
* Class for cats.
*/
class Cat { }
//make a banana
Cat c1 = new Cat();
//put the banana in a box
SingleItemBox<Cat> catPlayBox = new SingleItemBox<>(c1);
//check that the banana was put in the box
if(catPlayBox.getItem().equals(c1)) {
System.out.println("yay 3");
}
}
}