Answered step by step
Verified Expert Solution
Link Copied!

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 getReservationInfoPanel(JLabel typeToVerify){
/* creating panel for getting the reservation look up info */
this.centerPanel = new JPanel(new BorderLayout());
this.centerPanel.setBackground(new Color(161,158,158));
/* creating panels for top, middle, and bottom of reservaion look up panel */
JPanel top = new JPanel();
JPanel middle = new JPanel(new GridLayout(3,1));
JPanel bottom = new JPanel();
/* setting background colors for top, middle, and bottom panels */
top.setBackground(new Color(161,158,158));
middle.setBackground(new Color(161,158,158));
bottom.setBackground(new Color(161,158,158));
/*creating Reservation Information label, setting font attributes and adding label to top panel */
JLabel reviewRes = new JLabel("Reservation Information");
reviewRes.setFont(new Font("MV Boli", Font.PLAIN, 30));
top.add(reviewRes);
/* 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.setBackground(new Color(161,158,158));
promptPanel.setBackground(new Color(161,158,158));
namePanel.setBackground(new Color(161,158,158));
/* creating prompt label, setting font attributes and adding to prompt panel */
JLabel prompt = new JLabel("Enter The first and last name associated with the Reservation");
prompt.setFont(new Font("MV Boli", Font.PLAIN, 20));
promptPanel.add(prompt);
/* creating textfield for id/confirmation 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 JFormattedTextField(new MaskFormatter("AAAAAAA"));
inputToVerify.setColumns(20);
verifyPanel.add(typeToVerify);
verifyPanel.add(inputToVerify);
/* creating name label and textfield, adding label to appropiate panel */
JLabel firstNameLabel = new JLabel("First Name: ");
JLabel lastNameLabel = new JLabel("Last Name: ");
JTextField firstName = new JTextField(25);
JTextField lastName = new JTextField(25);
namePanel.add(firstNameLabel);
namePanel.add(firstName);
namePanel.add(lastNameLabel);
namePanel.add(lastName);
/* adding each attribute panel to the middle panel in the order they will appear */
middle.add(verifyPanel);
middle.add(promptPanel);
middle.add(namePanel);
/* creating continue button and setting background color */
JButton continueButton = new JButton("Continue");
continueButton.setBackground(new Color(153,153,153));
/*creating action listener for continue button */
continueButton.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e){
// checks if there is missing input for the first and last name
if (firstName.getText().equals("")|| lastName.getText().equals("")){
System.out.println("Please enter a first and last name");
}
else if (typeToVerify.getText().equals("Confirmation Number:")){
// verifies for confirmation number search, retrieves the reservation based on provided info, passes reservation to create panel in GUI
ReservationOptions res = hotelTest.getReservation(firstName.getText(), lastName.getText(), inputToVerify.getText(), "Confirmation Number");
scrollPane.setVisible(false);
reviewReservationPanel(res);
}
else if (typeToVerify.getText().equals("Customer ID:")){
// verifies for id number search, retrieves the reservation based on provided info, passes reservation to create panel in GUI
ReservationOptions res = hotelTest.getReservation(firstName.getText(), lastName.getText(), inputToVerify.getText(), "Customer ID");
scrollPane.setVisible(false);
reviewReservationPanel(res);
}
else {
// error message for any potential misinputs
System.out.println("Please enter a first and last name");
}
}
});

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions