Class Parser

java.lang.Object
javatro.display.Parser

public class Parser extends Object
Handles parsing and validation of user input for the Javatro application.

This class is responsible for:

  • Processing user input for card selections and menu navigation
  • Validating input ranges, formats, and constraints
  • Notifying registered observers of valid user input changes
  • Constructor Details

    • Parser

      public Parser()
  • Method Details

    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener pcl) throws JavatroException
      Registers an observer to listen for user input changes.
      Parameters:
      pcl - the property change listener to register
      Throws:
      JavatroException - if the provided listener is null
    • getOptionInput

      public void getOptionInput() throws JavatroException
      Handles user input for menu navigation and notifies observers.

      This method:

      • Displays current screen options
      • Validates input is within allowed range
      • Notifies listeners of valid input
      • Handles input errors with appropriate error messages
      Throws:
      JavatroException - if no options are available in current screen
    • getCardInput

      public static List<Integer> getCardInput(int maxCardsAvailable, int maxCardsToSelect)
      Collects and validates card selection input from the user.
      Parameters:
      maxCardsAvailable - maximum number of available cards (1-based)
      maxCardsToSelect - maximum number of cards allowed for selection
      Returns:
      unmodifiable list of 0-based card indices