Class Tables.TableData


public class Tables.TableData extends Employee.EmployeeData
Tables.TableData class represents the data for restaurant tables, including table number, number of seats, number of seats filled, and dishes ordered.
  • Constructor Details

    • Tables.TableData

      public Tables.TableData()
      Creates a new Tables.TableData object with 20 tables initialized with a Tables.Table object for each table.
  • 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
      Throws:
      RuntimeException - if the specified table number is not found in the table data
    • 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
    • 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
    • setSeatsFilled

      public void setSeatsFilled(int tableNumber, int seatsFilled)
      Sets the number of seats filled for the specified table.
      Parameters:
      tableNumber - the number of the table to set seats filled for
      seatsFilled - the number of seats filled to set for the table
      Throws:
      RuntimeException - if the specified table number is not found in the table data
    • getEmptySeats

      public int getEmptySeats(int tableNumber)
      Returns the number of empty seats at the specified table.
      Parameters:
      tableNumber - the number of the table
      Returns:
      the number of empty seats
      Throws:
      RuntimeException - if the table does not exist
    • getFilledSeats

      public int getFilledSeats(int tableNumber)
      Returns the number of filled seats at the specified table.
      Parameters:
      tableNumber - the number of the table
      Returns:
      the number of filled seats
      Throws:
      RuntimeException - if the table does not exist
    • getDishes

      public String getDishes(int tableNumber)
      Returns a string containing the dishes ordered at the specified table.
      Parameters:
      tableNumber - the number of the table
      Returns:
      a string containing the dishes ordered
      Throws:
      RuntimeException - if the table does not exist
    • addDish

      public void addDish(int tableNumber, int seatNumber, String dish)
      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
      dish - the name of the dish
      Throws:
      RuntimeException - if the table does not exist