Class BookingUIHelper
This class provides reusable UI components for displaying and managing booking data, including: - Displaying lists of bookings with applicant information - Facilitating user selection of bookings from a list - Formatting and displaying booking receipt information
The helper follows a composition pattern, working with a BaseUI instance for common UI operations and a UserController for retrieving applicant information.
-
Constructor Summary
ConstructorsConstructorDescriptionBookingUIHelper
(BaseUI baseUI, UserController userController) Constructs a new BookingUIHelper with the specified dependencies. -
Method Summary
Modifier and TypeMethodDescriptionvoid
displayBookingReceipt
(BookingReceiptInfo receiptInfo) Displays the formatted details of a booking receipt.selectBookingFromList
(List<Booking> bookings, String title) Displays a list of bookings and prompts the user to select one.
-
Constructor Details
-
BookingUIHelper
Constructs a new BookingUIHelper with the specified dependencies.- Parameters:
baseUI
- An instance of BaseUI for console I/O operationsuserController
- Controller to fetch user information for bookings- Throws:
NullPointerException
- if either parameter is null
-
-
Method Details
-
selectBookingFromList
Displays a list of bookings and prompts the user to select one.This method presents a formatted list of bookings with key information including: - Booking ID - Applicant NRIC and name - Flat type - Booking date
The method returns the selected booking object or null if the user cancels the selection or if the provided booking list is empty.
- Parameters:
bookings
- List of Booking objects to displaytitle
- Title for the list header- Returns:
- The selected Booking object, or null if cancelled or list is empty
-
displayBookingReceipt
Displays the formatted details of a booking receipt.This method presents a comprehensive receipt for a booking, including: - Booking ID and date - Applicant personal information (name, NRIC, age, marital status) - Project details (name, neighborhood) - Flat type information
The method handles null receipt information gracefully by displaying an error message instead of attempting to format a null object.
- Parameters:
receiptInfo
- The BookingReceiptInfo object containing receipt data
-