-
Notifications
You must be signed in to change notification settings - Fork 0
/
preorderTester.java
151 lines (126 loc) · 4.37 KB
/
preorderTester.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
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
/*************************
* preorderTester.java
* executable for testing a restaurant reservation and preorder app
* @author Chris Carmine
* @version 1.0
***********************/
public class preorderTester {
public static void main(String args[]){
String method;
String crit; //criteria
double dcrit;
boolean bcrit;
final double tol = .0001;
//test menuItem
menuItem test = new menuItem();
method = "menuItem get category";
crit = "No category";
if (test.getCategory().equals(crit)){
System.out.printf("%s Pass%n",method);
} else {
System.out.printf("%s FAIL%n",method);
}
method = "menuItem get description";
crit = "No description";
if (test.getItemDesc().equals(crit)){
System.out.printf("%s Pass%n",method);
} else {
System.out.printf("%s FAIL%n",method);
}
method = "menuItem get price";
dcrit = 0.0;
if (Math.abs(test.getItemPrice()-dcrit)<=tol){
System.out.printf("%s Pass%n",method);
} else {
System.out.printf("%s FAIL%n",method);
}
method = "menuItem isVerifiable";
bcrit = true;
if (test.isVerifiable() == bcrit){
System.out.printf("%s Pass%n",method);
} else {
System.out.printf("%s FAIL%n",method);
}
//test orderItem
menuItem testOrderMenuItem = new menuItem("App","Fries",4.99);
orderItem testOrder = new orderItem(testOrderMenuItem,3);
method = "orderItem toString";
crit = "Fries, qty 3, sub total $14.97";
if (testOrder.toString().equals(crit)){
System.out.printf("%s Pass%n",method);
} else {
System.out.printf("%s FAIL%n",method);
}
method = "orderItem verifyAge";
bcrit = false;
testOrder.verifyAge(false);
if (testOrder.isVerified() == bcrit){
System.out.printf("%s Pass%n",method);
} else {
System.out.printf("%s FAIL%n",method);
}
//test food
food foodTest = new food("category","item",1.00,"diet");
method = "food isVerifiable";
bcrit = false;
if (foodTest.isVerifiable() == bcrit){
System.out.printf("%s Pass%n",method);
} else {
System.out.printf("%s FAIL%n",method);
}
method = "food toString";
crit = "category, item, $1.00 diet";
if (foodTest.toString().equals(crit)){
System.out.printf("%s Pass%n",method);
} else {
System.out.printf("%s FAIL%n",method);
}
//test alcohol
alcohol alcoholTest = new alcohol("category","item",1.00, 5.0);
method = "alcohol isVerifiable";
bcrit = true;
if (alcoholTest.isVerifiable() == bcrit){
System.out.printf("%s Pass%n",method);
} else {
System.out.printf("%s FAIL%n",method);
}
method = "alcohol toString";
crit = "category, item, ABV: 5.0, $1.00";
if (alcoholTest.toString().equals(crit)){
System.out.printf("%s Pass%n",method);
} else {
System.out.printf("%s FAIL%n",method);
}
//test seating
seating seatingTest = new seating("booster");
method = "seating isVerifiable";
bcrit = false;
if (seatingTest.isVerifiable() == bcrit){
System.out.printf("%s Pass%n",method);
} else {
System.out.printf("%s FAIL%n",method);
}
method = "seating toString";
crit = "booster";
if (seatingTest.toString().equals(crit)){
System.out.printf("%s Pass%n",method);
} else {
System.out.printf("%s FAIL%n",method);
}
//test restaurant
restaurant restTest = new restaurant("test");
method = "restaurant getMenu";
if (restTest.getMenu().isEmpty()){
System.out.printf("%s Pass%n",method);
} else {
System.out.printf("%s FAIL%n",method);
}
method = "restaurant reserveSlot";
restTest.reserveSlot(0);
if (restTest.getTimes()[0][1].equals("Reserved") ){
System.out.printf("%s Pass%n",method);
} else {
System.out.printf("%s FAIL%n",method);
}
}
}