Class InventoryDisplay

java.lang.Object
com.mg105.user_interface.InventoryDisplay
All Implemented Interfaces:
Alert, InventoryViewInterface, Toggleable

public class InventoryDisplay extends Object implements 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 Details

    • InventoryDisplay

      public InventoryDisplay(InventoryController controller)
      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 interface Toggleable
      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 interface Toggleable
      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

      public void removeItemView(String name)
      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 interface InventoryViewInterface
      Parameters:
      name - the name of the item to be removed
    • alert

      public void alert(String msg)
      Opens a window displaying a message to the user
      Specified by:
      alert in interface Alert
      Parameters:
      msg - the message to alert the user with
    • addItemView

      public void addItemView(String name, String description, boolean isUsable, String quantity)
      Adds the details of the item to the display
      Specified by:
      addItemView in interface InventoryViewInterface
      Parameters:
      name - the name of the item to add
      description - the description of the item to add
      isUsable - true iff the item can be used by a user
      quantity - the number of items of this type in the Inventory
    • changeItemView

      public void changeItemView(String name, String description, boolean isUsable, String quantity)
      Changes the details of an already displayed item and displays the changes
      Specified by:
      changeItemView in interface InventoryViewInterface
      Parameters:
      name - the name of the item to change details about
      description - the description of the item
      isUsable - true iff the item is usable
      quantity - the number of items of this type in the Inventory