Class ShelfRegister
java.lang.Object
stud.ntnu.idatt1005.pantrypal.registers.Register<Shelf>
stud.ntnu.idatt1005.pantrypal.registers.ShelfRegister
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.
-
Field Summary
Fields inherited from class stud.ntnu.idatt1005.pantrypal.registers.Register
registerMap
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a shelf to the register.Grocery[]
Returns all groceries from all shelves in the register.protected String
Returns an error message when a shelf does not exist in the register.getShelfByName
(String nameOfShelf) Returns the shelf from the register that corresponds with name given.void
removeShelf
(Shelf shelf) Removes a shelf from the register.Methods inherited from class stud.ntnu.idatt1005.pantrypal.registers.Register
addModel, containsModel, getModel, getRegister, removeModel, searchModels
-
Constructor Details
-
ShelfRegister
public ShelfRegister()Constructor for ShelfRegister class. Calls the parent constructor.
-
-
Method Details
-
getErrorMessage
Returns an error message when a shelf does not exist in the register.- Specified by:
getErrorMessage
in classRegister<Shelf>
- Returns:
- a string error message.
-
getShelfByName
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
Adds a shelf to the register.- Parameters:
shelf
- the Shelf object to be added.
-
removeShelf
Removes a shelf from the register.- Parameters:
shelf
- the Shelf object to be removed.
-
getAllGroceries
Returns all groceries from all shelves in the register.- Returns:
- an array of Grocery objects.
-