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
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
displayError
(String message) Displays an error message to the console.static void
displaySuccess
(String message) Displays a success message to the console.protected static int
getIntInput
(int defaultReturn) Gets an integer input from the user and checks for input errors.protected static String
Gets a numeric string input from the user.protected int
getValidatedInt
(String prompt) Prompts the user for a positive integer value.protected String
getValidatedString
(String prompt) Prompts the user for a string input and checks for null or empty values.protected void
Pauses execution and waits for the user to press ENTER before returning to menu.
-
Field Details
-
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
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
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
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
Displays a success message to the console.- Parameters:
message
- the success message to display
-
displayError
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.
-