Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create code that provides valid test cases for the following try block found in the code below. Your help would be greatly appreciated!! public void
Create code that provides valid test cases for the following try block found in the code below. Your help would be greatly appreciated!!
public void getReservationInfoPanelJLabel typeToVerify
creating panel for getting the reservation look up info
this.centerPanel new JPanelnew BorderLayout;
this.centerPanel.setBackgroundnew Color;
creating panels for top, middle, and bottom of reservaion look up panel
JPanel top new JPanel;
JPanel middle new JPanelnew GridLayout;
JPanel bottom new JPanel;
setting background colors for top, middle, and bottom panels
top.setBackgroundnew Color;
middle.setBackgroundnew Color;
bottom.setBackgroundnew Color;
creating Reservation Information label, setting font attributes and adding label to top panel
JLabel reviewRes new JLabelReservation Information";
reviewRes.setFontnew FontMV Boli", Font.PLAIN, ;
top.addreviewRes;
creating panels for the verify prompt, and name labes and textfields
JPanel verifyPanel new JPanel;
JPanel promptPanel new JPanel;
JPanel namePanel new JPanel;
setting background colors for each panel
verifyPanel.setBackgroundnew Color;
promptPanel.setBackgroundnew Color;
namePanel.setBackgroundnew Color;
creating prompt label, setting font attributes and adding to prompt panel
JLabel prompt new JLabelEnter The first and last name associated with the Reservation";
prompt.setFontnew FontMV Boli", Font.PLAIN, ;
promptPanel.addprompt;
creating textfield for idconfirmation input, adding the label and textfield to verify panel
try
creating text field with input mask for cust id and confirm num
JFormattedTextField inputToVerify new JFormattedTextFieldnew MaskFormatterAAAAAAA;
inputToVerify.setColumns;
verifyPanel.addtypeToVerify;
verifyPanel.addinputToVerify;
creating name label and textfield, adding label to appropiate panel
JLabel firstNameLabel new JLabelFirst Name: ;
JLabel lastNameLabel new JLabelLast Name: ;
JTextField firstName new JTextField;
JTextField lastName new JTextField;
namePanel.addfirstNameLabel;
namePanel.addfirstName;
namePanel.addlastNameLabel;
namePanel.addlastName;
adding each attribute panel to the middle panel in the order they will appear
middle.addverifyPanel;
middle.addpromptPanel;
middle.addnamePanel;
creating continue button and setting background color
JButton continueButton new JButtonContinue;
continueButton.setBackgroundnew Color;
creating action listener for continue button
continueButton.addActionListenernew ActionListener
@Override
public void actionPerformedActionEvent e
checks if there is missing input for the first and last name
if firstNamegetTextequals lastName.getTextequals
System.out.printlnPlease enter a first and last name";
else if typeToVerifygetTextequalsConfirmation Number:"
verifies for confirmation number search, retrieves the reservation based on provided info, passes reservation to create panel in GUI
ReservationOptions res hotelTest.getReservationfirstNamegetText lastName.getText inputToVerify.getText "Confirmation Number";
scrollPane.setVisiblefalse;
reviewReservationPanelres;
else if typeToVerifygetTextequalsCustomer ID:
verifies for id number search, retrieves the reservation based on provided info, passes reservation to create panel in GUI
ReservationOptions res hotelTest.getReservationfirstNamegetText lastName.getText inputToVerify.getText "Customer ID;
scrollPane.setVisiblefalse;
reviewReservationPanelres;
else
error message for any potential misinputs
System.out.printlnPlease enter a first and last name";
;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started