Package Singletons
Class InputManager
java.lang.Object
Singletons.InputManager
-
Method Summary
Modifier and TypeMethodDescriptionboolean
getBoolean
(String message) Gets a boolean input from usergetDate()
Gets a date input from user Default message is "Enter date (dd-MM-yyyy): "Gets a date and time input from user<E extends Enum<E>>
EGets an enum input from userstatic InputManager
int
getInt()
Works just likegetInt(String)
but with no messageint
Gets an integer input from user Repeatedly asks for integer until a valid integer is enteredgetNewPasswordInput
(boolean passwordValidation) Gets a new password input from user Repeatedly asks for password until a valid password is entered Requires confirmation of password<T> T
getSelection
(String s, List<T> list) Works just likegetSelection(String, List, boolean)
but with no option to go back<T> SelectionResult
<T> getSelection
(String s, List<T> list, boolean allowBack) Gets a selection from a list of itemsWorks just likegetString(String)
but with no messageGets a string input from usergetTime()
Gets a time input from user Default message is "Enter time (HH:mm): "getUniqueString
(String message, Set<String> existingValues) Gets a unique string input from user (Useful for unique usernames, ids, etc.)int
Prompts user to press enter to go backselectTimeSlot
(LocalDate date, String patientId) Shows a list of available timeslots for the selected date and allows them to select one.boolean
validatePassword
(String password) Validate password
Password must be at least 8 characters long
Password must contain at least one digit, one lowercase letter, one uppercase letter, and one special character
Password must not contain spaces
Password cannot be 'password'
-
Method Details
-
getInstance
-
getInt
-
getInt
Gets an integer input from user Repeatedly asks for integer until a valid integer is entered- Parameters:
message
- message to display to user- Returns:
- valid integer entered by user
-
getString
-
getString
-
getUniqueString
-
getBoolean
Gets a boolean input from user- Parameters:
message
- message to display to user- Returns:
- true if user enters 'Y', false otherwise
-
goBackPrompt
public int goBackPrompt()Prompts user to press enter to go back- Returns:
- 1 to indicate to continue showing the previous menu
-
getTime
Gets a time input from user Default message is "Enter time (HH:mm): "- Returns:
- time entered by user
-
getDate
Gets a date input from user Default message is "Enter date (dd-MM-yyyy): "- Returns:
- date entered by user
-
getDate
-
getDateTime
Gets a date and time input from user- Returns:
- date and time entered by user
-
getScanner
-
getEnum
-
getSelection
Works just likegetSelection(String, List, boolean)
but with no option to go back- See Also:
-
getSelection
Gets a selection from a list of items- Type Parameters:
T
- type of items in list- Parameters:
s
- message to display to userlist
- list of items to choose fromallowBack
- whether to allow user to go back- Returns:
- item selected by user
-
getNewPasswordInput
Gets a new password input from user Repeatedly asks for password until a valid password is entered Requires confirmation of password- Parameters:
passwordValidation
- can toggle whether password validation is required (Mainly for testing)- Returns:
- valid password entered by user
-
validatePassword
Validate password
Password must be at least 8 characters long
Password must contain at least one digit, one lowercase letter, one uppercase letter, and one special character
Password must not contain spaces
Password cannot be 'password'- Parameters:
password
- password to validate- Returns:
- true if password is valid, false otherwise
-
getPrescription
-
selectTimeSlot
Shows a list of available timeslots for the selected date and allows them to select one.- Parameters:
date
- The date for which to select a timeslot.- Returns:
- The selected timeslot, or null if the user cancels the selection.
-