java.lang.Object
stud.ntnu.idatt1005.pantrypal.models.Model
stud.ntnu.idatt1005.pantrypal.models.Shelf

public class Shelf extends Model
This class represents a Shelf in the PantryPal application. A Shelf has a name and a register of groceries.
  • Field Details

  • Constructor Details

    • Shelf

      public Shelf(String name)
      Constructor for Shelf class.
      Parameters:
      name - the name of the shelf
    • Shelf

      public Shelf(String key, String name)
      Constructor for Shelf class with key parameter.
      Parameters:
      key - the key of the shelf
      name - the name of the shelf
  • Method Details

    • getName

      public String getName()
      Gets the name of the shelf.
      Returns:
      the name of the shelf
    • getGroceryRegister

      public GroceryRegister getGroceryRegister()
      Gets the register of groceries on the shelf.
      Returns:
      the register of groceries on the shelf
    • getGroceries

      public Map<String,Grocery> getGroceries()
      Gets the map of groceries in the register of the shelf.
      Returns:
      a HashMap of groceries on the shelf
    • setName

      public void setName(String name)
      Sets the name of the shelf.
      Parameters:
      name - the new name of the shelf
    • addGrocery

      public void addGrocery(Grocery grocery)
      Adds a grocery item to the shelf.
      Parameters:
      grocery - the grocery item to be added
    • removeGrocery

      public void removeGrocery(Grocery grocery)
      Removes a grocery item from the shelf.
      Parameters:
      grocery - the grocery item to be removed