Package com.mg105.user_interface
Class InventoryDisplay
java.lang.Object
com.mg105.user_interface.InventoryDisplay
- All Implemented Interfaces:
Alert
,InventoryViewInterface
,Toggleable
A user interface class that displays the state of the inventory to the user and allows them to
perform actions that relate to the inventory and its items.
-
Constructor Summary
ConstructorsConstructorDescriptionInventoryDisplay
(InventoryController controller) Creates a new instance of inventory display -
Method Summary
Modifier and TypeMethodDescriptionvoid
addItemView
(String name, String description, boolean isUsable, String quantity) Adds the details of the item to the displayvoid
Opens a window displaying a message to the uservoid
changeItemView
(String name, String description, boolean isUsable, String quantity) Changes the details of an already displayed item and displays the changes@NotNull javafx.scene.Scene
getScene()
Returns the scene that displays the information for the Inventoryvoid
removeItemView
(String name) Removes an item from the inventory ui.void
toggle
(boolean isVisible) Changes the state of the InventoryDisplay based on if the inventory display is shown in the ui
-
Constructor Details
-
InventoryDisplay
Creates a new instance of inventory display- Parameters:
controller
- an object that interprets user inputs to make changes about the inventory
-
-
Method Details
-
getScene
@NotNull public @NotNull javafx.scene.Scene getScene()Returns the scene that displays the information for the Inventory- Specified by:
getScene
in interfaceToggleable
- Returns:
- the scene that displays the information for the Inventory.
-
toggle
public void toggle(boolean isVisible) Changes the state of the InventoryDisplay based on if the inventory display is shown in the ui- Specified by:
toggle
in interfaceToggleable
- Parameters:
isVisible
- true if the Toggleable is now visible, false otherwise. If false the Toggleable is expected to do nothing on ANY user inputs.
-
removeItemView
Removes an item from the inventory ui. Precondition there must not be an items of the type name in the inventory- Specified by:
removeItemView
in interfaceInventoryViewInterface
- Parameters:
name
- the name of the item to be removed
-
alert
Opens a window displaying a message to the user -
addItemView
Adds the details of the item to the display- Specified by:
addItemView
in interfaceInventoryViewInterface
- Parameters:
name
- the name of the item to adddescription
- the description of the item to addisUsable
- true iff the item can be used by a userquantity
- the number of items of this type in the Inventory
-
changeItemView
Changes the details of an already displayed item and displays the changes- Specified by:
changeItemView
in interfaceInventoryViewInterface
- Parameters:
name
- the name of the item to change details aboutdescription
- the description of the itemisUsable
- true iff the item is usablequantity
- the number of items of this type in the Inventory
-