Package Tables

Class TableData

java.lang.Object
Tables.TableData

public class TableData extends Object
TableData class represents the data for restaurant tables, including table number, number of seats, number of seats filled, and dishes ordered.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initializes 20 empty tables to the tableData hashmap.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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 tables
    getTable(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 hashmap
    boolean
    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.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TableData

      public TableData()
      Initializes 20 empty tables to the tableData hashmap.
  • Method Details

    • getTableData

      public String getTableData(int tableNumber)
      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

      public Table getTable(int tableNumber)
      Returns the table object for a specified table.
      Parameters:
      tableNumber - the number of the table to get data for
      Returns:
      a table object
    • listTables

      public String 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 table
      seatNumber - the number of the seat
      dishNum - 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 table
      seatNumber - 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

      public String getEmptyTables()
      Returns a formatted string with the numbers of all empty tables
      Returns:
      a string listing the numbers of all empty tables