-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrder.java
182 lines (164 loc) · 5.12 KB
/
Order.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
// Jason Jasper
// David Martin-Vaquero
// Jared Mclaren
// Regine Villongco
// Chemen Wong
import java.util.ArrayList;
/**
* IS 380 Final Project - Restaurant Point of Sale program.
* @author Jason Jasper, David Martin-Vaquero, Jared Mclaren, Regine Villongco, Chemen Wong
* @version 0.1.0
*
* This is the Order class. It is the object abstraction that will hold all the different orders
* for tables. Table is the parent class since Order belongs to Table.
*/
public class Order extends Table {
/*
THIS CLASS WILL STORE ORDER DATA.
THE HIERARCHY SHOULD BE TABLE HAS AN ORDER HAS ITEMS.
ONLY ONE ORDER PER TABLE.
*/
static int orderNumbers; //INCREMENT (COUNT) ORDER NUMBERS.
static double totalSales; //TRACK TOTAL SALES.
static double totalTax; //TRACK TOTAL TAX.
static double totalTips; //TRACK TOTAL TIPS.
private int thisOrderNumber;
private int tableNumber;
private ArrayList<Item> itemList = new ArrayList<Item>();
private String orderNote = "";
/**
Default Constructor for order, no parameters passed.
*/
public Order() {
}
/**
Constructor for order.
@param A table number.
*/
public Order(int tableNum) {
orderNumbers++;
thisOrderNumber = orderNumbers; //Retain current order number.
tableNumber = tableNum;
System.out.println("Order #" + thisOrderNumber + " For Table #" + tableNumber + " Created.");
//Table.startNewOrder(tableNumber);
}
/**
Method to add to total sales tally. (Pre-tax, and tip)
@param double thisSale amount of sale.
*/
public static void addSales(double thisSale) {
totalSales += thisSale;
System.out.println("Total sales so far: " + totalSales);
}
public static void addTax(double thisTax) {
totalTax += thisTax;
System.out.println("Total tax so far: " + totalTax);
}
public static void addTips(double thisTip) {
totalTips += thisTip;
System.out.println("Total tips so far: " + totalTips);
}
/**
Method to add food items to array.
@param Item's index number.
*/
public void addFoodItems(int itemIndex) {
itemList.add(new Item(itemIndex, "Food"));
Item thisguy = itemList.get(itemList.size()-1);
System.out.println(thisguy.getItemName());
}
/**
Method to subtract food items from array.
@param ArrayList index number.
*/
public void subFoodItems(int arrayListIndex) {
System.out.println("Deleting item at index " + arrayListIndex);
itemList.remove(arrayListIndex);
}
/**
Method to set an item as comped in the Item list.
@param ArrayList index number.
*/
public void compFoodItems(int arrayListIndex) {
Item thisItem = itemList.get(arrayListIndex);
thisItem.setComped();
itemList.set(arrayListIndex, thisItem);
}
/**
Method to add beverage items to array.
@param Item's index number.
*/
public void addBeverageItems(int itemIndex) {
itemList.add(new Item(itemIndex, "Beverage"));
Item thisguy = itemList.get(itemList.size()-1);
System.out.println(thisguy.getItemName());
}
/**
Method to subtract beverage items from array.
@param ArrayList index number.
*/
public void subBeverageItems(int arrayListIndex) {
itemList.remove(arrayListIndex);
}
/**
Method for setting order note.
@param Order note.
*/
public void setOrderNote (String note) {
this.orderNote = note;
}
/**
Method for getting order note.
@return Order note.
*/
public String getOrderNote() {
return this.orderNote;
}
/**
Method for getting order number.
@return Order number.
*/
public int getOrderNumber() {
return thisOrderNumber;
}
/**
Method to get subtotal.
@return Subtotal.
*/
public double getSubTotal() {
double subtotal = 0;
for (int i=0; i<itemList.size(); i++) {
// Total item's prices.
Item tallyItem = itemList.get(i);
subtotal += tallyItem.getItemPrice();
}
return subtotal;
}
/**
Method to get order items, ignoring comped items..
@return Array of order items.
*/
public String[] getOrderItemList() {
String[] thisItemList = new String[itemList.size()];
for (int i=0; i<itemList.size(); i++) {
Item listItem = itemList.get(i);
if (!listItem.getComped()) { //If the item isn't comped, add it to the list. This also adds very small blank lines to the list.
// Add non-comped items to the array.
thisItemList[i] = listItem.getItemName();
}
}
return thisItemList;
}
/**
Method to get total order items including comped items.
@return Array of order items.
*/
public String[] getTotalOrderItemList() {
String[] thisItemList = new String[itemList.size()];
for (int i=0; i<itemList.size(); i++) {
// Add items to the array.
Item listItem = itemList.get(i);
}
return thisItemList;
}
}