Package Orders
Class OrderData
java.lang.Object
Orders.OrderData
This class creates an order data object and provides methods to add, search, list, and remove orders.
It also provides methods to get a new order number and check if an order exists. It uses a hashmap to
store orders with the order number used as the key.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new MenuData object and loads the default menu items from the default_menu_items.txt file. -
Method Summary
Modifier and TypeMethodDescriptionvoid
This adds an order object to the orderData hashmapint
This method returns an order number and then increments the order numbergetOrder
(int orderNumber) This method returns an order object from the orderData hashmapboolean
isOrder
(int orderNum) This method checks if an order number exists in the orderData hashmapThis method prints out all the information for all the orders in the orderData hashmapvoid
remOrder
(int orderNumber) Removes the order object with this order numbersearchOrder
(int orderNumber) This method searches the orderData hashmap for an order number and, if found, build a string of its information and returns that string
-
Constructor Details
-
OrderData
public OrderData()Constructs a new MenuData object and loads the default menu items from the default_menu_items.txt file.
-
-
Method Details
-
addOrder
This adds an order object to the orderData hashmap- Parameters:
orderNumber
- takes the order number keyorder
- takes the order object
-
getOrder
This method returns an order object from the orderData hashmap- Parameters:
orderNumber
- the order number to search for- Returns:
- returns the order object
-
searchOrder
This method searches the orderData hashmap for an order number and, if found, build a string of its information and returns that string- Parameters:
orderNumber
- this is the order number searched for- Returns:
- returns the built string of order information
-
listOrders
This method prints out all the information for all the orders in the orderData hashmap -
isOrder
public boolean isOrder(int orderNum) This method checks if an order number exists in the orderData hashmap- Parameters:
orderNum
- The order number to be searched for- Returns:
- returns true if the order number is found
-
remOrder
public void remOrder(int orderNumber) Removes the order object with this order number- Parameters:
orderNumber
- this is the order number of the order object to be removed
-
getNewOrderNum
public int getNewOrderNum()This method returns an order number and then increments the order number- Returns:
- the current value of the order number index
-