java.lang.Object
it.polimi.ingsw.am13.client.view.tui.menu.MenuItem
Direct Known Subclasses:
MenuItemChangeField, MenuItemChooseObj, MenuItemCreateRoom, MenuItemDisableLegend, MenuItemEnableLegend, MenuItemEnterChat, MenuItemJoinRoom, MenuItemLeaveChat, MenuItemLeaveRoom, MenuItemPickCard, MenuItemPlayCard, MenuItemPlayStarter, MenuItemReconnect, MenuItemSendChatMessage, MenuItemUpdateRoomList

public abstract class MenuItem extends Object
Item belonging to a menu. It stores the command key with which it is possible to invoke the command, and its description. The focal point of this abstraction if the method which actually executes the command it represents.
  • Field Details

    • commandKey

      private final String commandKey
      Command key with which it is possible to invoke the command via the command line
    • description

      private final String description
      Description of the command. It should contain the list of arguments for the command to work, too
  • Constructor Details

    • MenuItem

      public MenuItem(String commandKey, String description)
      Build a new menu item
      Parameters:
      commandKey - Command key with which it is possible to invoke the command
      description - Description of the command
  • Method Details

    • executeCommand

      public abstract void executeCommand(String argsStr, NetworkHandler networkHandler) throws InvalidTUICommandException
      Executes the action this menu item represents
      Parameters:
      argsStr - String of parameters for the command
      networkHandler - Handler of the network thanks to which the item sends the command to the server
      Throws:
      InvalidTUICommandException - If the arguments passed via command line are wrong, or anyway different from what expected
    • getCommandKey

      public String getCommandKey()
      Returns:
      Command key with which it is possible to invoke the command via the command line
    • getDescription

      public String getDescription()
      Returns:
      Description of the command. It should contain the list of arguments for the command to work, too
    • toString

      public String toString()
      Overrides:
      toString in class Object