Package Common

Class UserInterface

java.lang.Object
Common.UserInterface
Direct Known Subclasses:
ApproveReplenishRequestPage, CancelAppointmentPage, DoctorOutcomeInterface, HandleAppointmentRequestsPage, HomePage, InventoryManagementPage, LoginPage, ManageMedicalRecordPage, ManageStaffPage, PatientOutcomeInterface, PatientViewMedicalRecordPage, PharmaOutcomeInterface, RescheduleAppointmentPage, ScheduleAppointmentPage, SetAvailabilityPage, StockRequestPage, UpdateDetailsPage, UserMenu, ViewAppointmentsDetailsPage, ViewAvailableAppointmentsPage, ViewInventoryPage, ViewPersonalSchedulePage, ViewScheduledAppointmentsPage, ViewUpcomingAppointmentsPage

public class UserInterface extends Object
The UserInterface class provides methods for user input handling, including validation of integer and string inputs. It facilitates interaction with the user through the console.
  • Field Details

    • scanner

      protected static Scanner scanner
  • Constructor Details

    • UserInterface

      public UserInterface()
  • Method Details

    • getIntInput

      protected static int getIntInput(int defaultReturn)
      Gets an integer input from the user and checks for input errors. If an error occurs, it returns a default value.
      Parameters:
      defaultReturn - the value to return in case of an input error
      Returns:
      the integer input from the user or the default value if an error occurs
    • getNumericString

      protected static String getNumericString()
      Gets a numeric string input from the user. This method continues to prompt until a valid numeric string is entered.
      Returns:
      a string containing only numeric characters
    • getValidatedInt

      protected int getValidatedInt(String prompt)
      Prompts the user for a positive integer value.
      Parameters:
      prompt - the message to display to the user
      Returns:
      the positive integer entered by the user, or -1 if invalid
    • getValidatedString

      protected String getValidatedString(String prompt)
      Prompts the user for a string input and checks for null or empty values.
      Parameters:
      prompt - the message to display to the user
      Returns:
      the trimmed string entered by the user, or null if empty
    • displaySuccess

      public static void displaySuccess(String message)
      Displays a success message to the console.
      Parameters:
      message - the success message to display
    • displayError

      public static void displayError(String message)
      Displays an error message to the console.
      Parameters:
      message - the error message to display
    • pauseAndView

      protected void pauseAndView()
      Pauses execution and waits for the user to press ENTER before returning to menu.