java.lang.Object
stud.ntnu.idatt1005.pantrypal.models.Model
stud.ntnu.idatt1005.pantrypal.models.Shelf
This class represents a Shelf in the PantryPal application.
A Shelf has a name and a register of groceries.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGrocery(Grocery grocery) Adds a grocery item to the shelf.Gets the map of groceries in the register of the shelf.Gets the register of groceries on the shelf.getName()Gets the name of the shelf.voidremoveGrocery(Grocery grocery) Removes a grocery item from the shelf.voidSets the name of the shelf.
-
Field Details
-
name
-
groceryRegister
-
-
Constructor Details
-
Shelf
Constructor for Shelf class.- Parameters:
name- the name of the shelf
-
Shelf
Constructor for Shelf class with key parameter.- Parameters:
key- the key of the shelfname- the name of the shelf
-
-
Method Details
-
getName
Gets the name of the shelf.- Returns:
- the name of the shelf
-
getGroceryRegister
Gets the register of groceries on the shelf.- Returns:
- the register of groceries on the shelf
-
getGroceries
Gets the map of groceries in the register of the shelf.- Returns:
- a HashMap of groceries on the shelf
-
setName
Sets the name of the shelf.- Parameters:
name- the new name of the shelf
-
addGrocery
Adds a grocery item to the shelf.- Parameters:
grocery- the grocery item to be added
-
removeGrocery
Removes a grocery item from the shelf.- Parameters:
grocery- the grocery item to be removed
-