java.lang.Object
stud.ntnu.idatt1005.pantrypal.registers.Register<Shelf>
stud.ntnu.idatt1005.pantrypal.registers.ShelfRegister

public class ShelfRegister extends Register<Shelf>
This class represents a register of shelves in the PantryPal application. It extends the Register class with type parameter Shelf. It contains methods for adding and removing shelves, and getting all groceries from all shelves.
  • Constructor Details

    • ShelfRegister

      public ShelfRegister()
      Constructor for ShelfRegister class. Calls the parent constructor.
  • Method Details

    • getErrorMessage

      protected String getErrorMessage()
      Returns an error message when a shelf does not exist in the register.
      Specified by:
      getErrorMessage in class Register<Shelf>
      Returns:
      a string error message.
    • getShelfByName

      public Shelf getShelfByName(String nameOfShelf)
      Returns the shelf from the register that corresponds with name given.
      Parameters:
      nameOfShelf - the name of the shelf to be retrieved.
      Returns:
      the Shelf object.
    • addShelf

      public void addShelf(Shelf shelf)
      Adds a shelf to the register.
      Parameters:
      shelf - the Shelf object to be added.
    • removeShelf

      public void removeShelf(Shelf shelf)
      Removes a shelf from the register.
      Parameters:
      shelf - the Shelf object to be removed.
    • getAllGroceries

      public Grocery[] getAllGroceries()
      Returns all groceries from all shelves in the register.
      Returns:
      an array of Grocery objects.