Package Tables
Class TableData
java.lang.Object
Tables.TableData
TableData class represents the data for restaurant tables, including table number,
number of seats, number of seats filled, and dishes ordered.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDish
(int tableNumber, int seatNumber, int dishNum) Adds a dish to the order at the specified seat at the specified table.void
clearSeat
(int tableNumber, int seatNumber) Returns a formatted string with the numbers of all empty tablesgetTable
(int tableNumber) Returns the table object for a specified table.getTableData
(int tableNumber) Returns the data for a specified table as a formatted string.double
getTotal
(int tableNumber) Returns the table bill from the tableData hashmapboolean
isFilled
(int tableNumber) Returns true if the specified table has 4 or more seats filled, false otherwise.boolean
isSeatEmpty
(int tableNumber, int seatNumber) Returns true if the specified seat at the specified table is empty, false otherwise.boolean
isTable
(int tableNumber) Returns true if the specified table exists, false otherwise.Returns a formatted string with data for all tables in the table data.
-
Constructor Details
-
TableData
public TableData()Initializes 20 empty tables to the tableData hashmap.
-
-
Method Details
-
getTableData
Returns the data for a specified table as a formatted string.- Parameters:
tableNumber
- the number of the table to get data for- Returns:
- a string with the table number, seats filled, and dishes ordered; or returns Table not found if Table doesn't exist.
-
getTable
Returns the table object for a specified table.- Parameters:
tableNumber
- the number of the table to get data for- Returns:
- a table object
-
listTables
Returns a formatted string with data for all tables in the table data.- Returns:
- a string with the table number, seats filled, and dishes ordered for all tables
-
isTable
public boolean isTable(int tableNumber) Returns true if the specified table exists, false otherwise.- Parameters:
tableNumber
- the number of the table to check for existence- Returns:
- true if the specified table exists, false otherwise
-
isFilled
public boolean isFilled(int tableNumber) Returns true if the specified table has 4 or more seats filled, false otherwise.- Parameters:
tableNumber
- the number of the table to check for filling- Returns:
- true if the specified table is filled, false otherwise
- Throws:
RuntimeException
- if the specified table number is not found in the table data
-
addDish
public void addDish(int tableNumber, int seatNumber, int dishNum) Adds a dish to the order at the specified seat at the specified table.- Parameters:
tableNumber
- the number of the tableseatNumber
- the number of the seatdishNum
- the number of the dish or returns Table not found if Table doesn't exist.
-
clearSeat
public void clearSeat(int tableNumber, int seatNumber) -
isSeatEmpty
public boolean isSeatEmpty(int tableNumber, int seatNumber) Returns true if the specified seat at the specified table is empty, false otherwise.- Parameters:
tableNumber
- the number of the tableseatNumber
- the number of the seat- Returns:
- true if the specified seat at the specified table is empty, false otherwise
- Throws:
RuntimeException
- if the specified table number is not found in the table data
-
getTotal
public double getTotal(int tableNumber) Returns the table bill from the tableData hashmap- Parameters:
tableNumber
- the number of the table- Returns:
- The total bill of the table from the tableData hashmap
-
getEmptyTables
Returns a formatted string with the numbers of all empty tables- Returns:
- a string listing the numbers of all empty tables
-