QuestionQuestion

Transcribed TextTranscribed Text

Objectives: • To practice writing and testing programmer-defined classes. • To practice defining and using an array of objects. • To gain experience in developing program logic. • To practicing writing documentation that explains what individual parts of the programmerdefined class and the application class do. The Problem: A small airline has decided to create a new automated system for reservations. You have been hired to write the program for this system. Customers will be allowed to book a reservation, cancel an existing reservation and request a seating chart. The airline currently offers a single flight per day on its only plane that has a capacity of 10 seats. Specifications: To complete this assignment you will need to design and implement three classes: an application class (Project6App.java), a Seat class (Seat.java), and an Airplane class (Airplane.java). The specifications for each are outlined below. All classes will be part of a project called proj6 (recall that the project name should be all lower-case letters). Initially you should define only the Seat class and the application class. The application class should be used to test all constructors/methods in the Seat class prior to its use in the Airplane class. Recall that the package name should be specified when creating classes and that it should have the same name as the project. The Seat class should define instance variables to store the type of seat (first or coach), whether the seat is empty or reserved, and the seat number. You should think about the data type that would be most appropriate for each. The Seat class should provide the following behaviors: • A parameterized constructor – the constructor will accept values for the seat number and the type of seat and store this information appropriately. Initially, the seat should be marked as empty. • Appropriate methods to: o Retrieve the seat number. o Return the type of seat (first/coach). o Check if it is empty – the method will return true if the seat is empty and false if it is reserved. o Reserve a seat – note that after reserving it, the seat is not empty. o Cancel a reservation – note that after canceling it, the seat is empty. o Return a reference to a String containing the state of the Seat (ie. the toString method) The format should be: Seat X - First Class - Empty Indicating the seat number (replace X with the number), the class (First Class or Coach) and whether it is Reserved or Empty. Page 2 of 16 The Seat class should be defined and tested (in Project6App.java) before beginning development of the Airplane class. Note that Web-CAT will only check that the output produced from this project is correct; it will not check your design. You are the designer of the Seat class, so use the best practices you learned this semester to design this class. Each constructor/method should be documented using Javadoc comments. Make sure the Javadoc explains the method to a person not familiar with the code. You should thoroughly test the Seat class to make sure that a seat can be created and displayed, that you can determine whether or not it is empty, and that it can be assigned to a passenger and canceled. If you are, for any reason, uncertain about the validity of the Seat class you have developed, please speak with me or email me prior to beginning development of the Airplane class. Once the Seat class is working correctly, you can begin working on the Airplane class. Comment out the code used for testing the Seat class; do not delete it. Modify the existing project by creating a new class called Airplane. An object of type Airplane will contain seats and will provide methods that allow the application class to request/cancel a reservation and to display a seating chart. There are multiple ways in which to design and implement the Airplane and the application classes. You should thoroughly read the descriptions for both prior to developing your code. The Airplane class should define an instance variable that can refer to a Seat array. Additional instance variables may or may not be needed depending upon your design. The Airplane class should provide the following behaviors: • A default constructor that creates the Seat array (recall that the plane has a capacity of 10 seats) and creates 10 Seat objects using the parameterized constructor defined in the Seat class – you can assume that there are 4 first class and 6 coach class seats on the plane. • Appropriate method(s) to: o Reserve a first class/coach class seat. The next available seat should be assigned. o Cancel a first class/coach class seat. o Return a reference to a String containing the state of the Airplane. This method will rely on the information returned by the toString method defined in the Seat class. Initially all the seats will be empty and the method should return: Seat 1 - First Class – Empty Seat 2 - First Class – Empty Seat 3 - First Class – Empty Seat 4 - First Class – Empty Seat 5 - Coach – Empty Seat 6 - Coach – Empty Seat 7 - Coach – Empty Seat 8 - Coach – Empty Seat 9 - Coach – Empty Seat 10 - Coach - Empty Each constructor/method should be documented using Javadoc comments. Make sure the Javadoc explains the methods to a person not familiar with the code. Note that Web-CAT will only check that the output produced from this project is correct; it will not check your design. You are the designer of the Airplane class, so use the best practices you learned this semester to design this class. Page 3 of 16 The GUI Class In the Blackboard Project 6 folder, you’ll find gui.jar that should be downloaded and added to your project .To import gui.jar as a library to your project: Download the gui.jar file into your proj6 folder in your workspace. 1. Click the Project menu item in Eclipse, then click Properties. • Click Java Build Path • Click Libraries • Click Add External JARs. • Browse to locate the gui.jar file in the proj6 directory and select it. • Click Open. • Click Finish/Ok. The gui.jar file just imported contains code for the GUI class. In the Project6App main method, you should use the static methods in the GUI class to display dialog boxes to the user. These dialog boxes are pop up windows, with buttons and text boxes for the user to enter values. The GUI class will also generate output to the console, which will be checked by Web-CAT for correct output. See GUI documentation below: Class GUI public class GUI Title: The Graphical User Interface Class Description: This class provides access to dialog boxes for user interaction. Author: CSC 120 Instructor Method Detail showMessageDialog public static void showMessageDialog(String msg, String title) showMessageDialog method -- this method displays a pop-up dialog box window with the message specified by the parameter msg and a window title specified by the parameter title. Parameters: msg – a String containing the text to be displayed title - a String containing the text for the name of the window showInputDialog public static String showInputDialog(String msg, String title) showInputDialog method -- this method displays a pop-up dialog box window in which the user can input an integer. The message to the user is specified by the parameter msg and a window title specified by the parameter title. Parameters: msg – a String containing the text to be displayed title - a String containing the text for the name of the window Returns: The String entered by the user Page 4 of 16 showOptionDialog public static int showOptionDialog(String msg, String title, String[] choices) showOptionDialog method -- this method displays a pop-up dialog box window in which the user can can choose from an array of options, specified by the String[] choices. The message to the user is specified by the parameter msg and a window title specified by the parameter title. Parameters: msg – a String containing the text to be displayed title - a String containing the text for the name of the window choices - a String array containing the text options for each of the buttons Returns: An integer corresponding to the button clicked by the user showMessageDialog example: GUI.showMessageDialog("The value of x is " + x, "Display Value"); would display the following dialog box assuming that 10 stored in the variable x. showInputDialog example: String name = GUI.showInputDialog("Please enter your name", "Input"); would display the following dialog box. The user enters the name and it is stored in the variable name. To convert Strings to numbers, see the Google Docs presentation on class methods. Specifically, see the Integer and Double classes, and the parseInt and parseDouble methods. Page 5 of 16 showOptionDialog example: String[] choices = {"Option 1", "Option 2", "Option 3", "Option 4"}; int choice = GUI.showOptionDialog("Enter your choice…", "Main Menu", choices); would display the following dialog box and choice would get a value of 0, 1, 2, or 3 depending on the choice selected by the user. If a 0 is returned, the user clicked the “Option 1” button. If a 1 is returned, the user clicked the “Option 2” button, etc… Application Class – The Airplane Reservation System The application class (Project6App) should: • Create an Airplane object. • Display a menu, using the showOptionDialog method defined in the GUI class, which provides the user with the options outlined above (make a reservation, cancel a reservation, display a seating chart, and quit) and get the user's choice. The user should be given the message “What would you like to do?” The title on the dialog box should be “CSC 120 Airline Main Menu” The four choices shown to the user should be: "Make a reservation", "Cancel a reservation", "Display a seating chart", "Quit" • Process the user’s choice (call the appropriate method in the Airplane class to handle the request). o If the user wants to make a reservation, your program should determine whether they want a first class or coach seat. Use a showOptionDialog box with the following: The user should be given the message “Choose seat class” The title on the dialog box should be “Reserve Seat” The two choices shown to the user should be: "First Class", "Coach" Page 6 of 16 o If seats are available in the requested class, then a seat should be assigned. The program should display a dialog box indicating that the reservation is complete and which seat was assigned as well as which class the seat is in. Use the showMessageDialog box with the following: The user should be given this message, replace X with the seat number. “Reservation successful! First Class seat X is reserved.” or “Reservation successful! Coach seat X is reserved.” The title on the dialog box should be “Reservation Result” o If there are no more seats in the requested class, your program should display a dialog box indicating why the request can not be satisfied. Use the showMessageDialog box with the following: The user should be given this message, replace X with the seat number. “No reservation made. There are no available seats in first class.” or “No reservation made. There are no available seats in coach.” The title on the dialog box should be “Reservation Result” o If the user wants to cancel a reservation, your program should handle the request by asking for the seat number of the seat that is being canceled. Use the showInputDialog box with the following: The user should be given this message. “Enter the seat number to cancel:” The title on the dialog box should be “Cancel Seat” o Be sure the user selects a valid seat number and one that is currently reserved. If the cancellation can be completed, display a dialog box indicating that the reservation for seat number # has been canceled. If the request can not be satisfied, your program should display a dialog box indicating why the request can not be satisfied. Use the showMessageDialog box with the following: The user should be given this message, replace X with the seat number. “Cancelation successful. Seat number X has been canceled.” or “Cancelation unsuccessful. The seat is empty or the seat number is invalid.” The title on the dialog box should be “Cancelation Result” Page 7 of 16 o If the user wants to view a seating chart, your program should display the seating chart in a dialog box indicating which seats are reserved and which are empty. Use the showMessageDialog box with the following: The user should be given a message with the String returned from a call to the Airplane toString method. The title on the dialog box should be “Seating Chart” o If the user chooses to quit, the program should terminate. • The main menu should be displayed and the user’s choice should be processed until s/he chooses to quit. • Include comments that describe what the application class does. You are required to use GUI methods to display menus, prompt the user for input, and/or to display output. All Input/Output must be done using GUI dialog boxes with the exact textual guidelines shown above. Web-CAT is expecting output according to the requirements specified above. Page 8 of 16 Test Scenario #1 In this scenario, the user chooses to display a seating chart, and a seating chart with 10 empty seats is displayed. Then the user quits. Note: blank lines are not counted. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Seating Chart ***** Seat 1 - First Class - Empty Seat 2 - First Class - Empty Seat 3 - First Class - Empty Seat 4 - First Class - Empty Seat 5 - Coach - Empty Seat 6 - Coach - Empty Seat 7 - Coach - Empty Seat 8 - Coach - Empty Seat 9 - Coach - Empty Seat 10 - Coach - Empty ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit Test Scenario #2 The user reserves 4 seats, and a seating chart is displayed. Then the user quits. Note: blank lines are not counted. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! First Class seat 1 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! Coach seat 5 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit User chooses “Display a seating chart.” User chooses “Quit.” User chooses “Make a reservation,” then “First Class.” User chooses “Make a reservation,” then “Coach.” User chooses “Make a reservation,” then “Coach.” Page 9 of 16 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! Coach seat 6 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! First Class seat 2 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Seating Chart ***** Seat 1 - First Class - Reserved Seat 2 - First Class - Reserved Seat 3 - First Class - Empty Seat 4 - First Class - Empty Seat 5 - Coach - Reserved Seat 6 - Coach - Reserved Seat 7 - Coach - Empty Seat 8 - Coach - Empty Seat 9 - Coach - Empty Seat 10 - Coach - Empty ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit Test Scenario #3 The user reserves all 10 seats, attempts to reserve 2 more seats and is shown a message that there are no seats available. A seating chart is displayed. Then the user quits. Note: blank lines are not counted. 1 2 3 4 5 6 7 8 9 10 11 ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! First Class seat 1 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit User chooses “Make a reservation,” then “First Class.” User chooses “Display a seating chart.” User chooses “Quit.” User chooses “Make a reservation,” then “First Class.” User chooses “Make a reservation,” then “Coach.” Page 10 of 16 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! Coach seat 5 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! Coach seat 6 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! First Class seat 2 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! Coach seat 7 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! Coach seat 8 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach User chooses “Make a reservation,” then “Coach.” User chooses “Make a reservation,” then “First Class.” User chooses “Make a reservation,” then “Coach.” User chooses “Make a reservation,” then “Coach.” User chooses “Make a reservation,” then “First Class.” Page 11 of 16 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 ***** Reservation Result ***** Reservation successful! First Class seat 3 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! Coach seat 9 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! First Class seat 4 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! Coach seat 10 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** No reservation made. There are no available seats in first class. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** No reservation made. There are no available seats in coach. User chooses “Make a reservation,” then “Coach.” User chooses “Make a reservation,” then “First Class.” User chooses “Make a reservation,” then “Coach.” User chooses “Make a reservation,” then “First Class.” User chooses “Make a reservation,” then “Coach.” Page 12 of 16 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Seating Chart ***** Seat 1 - First Class - Reserved Seat 2 - First Class - Reserved Seat 3 - First Class - Reserved Seat 4 - First Class - Reserved Seat 5 - Coach - Reserved Seat 6 - Coach - Reserved Seat 7 - Coach - Reserved Seat 8 - Coach - Reserved Seat 9 - Coach - Reserved Seat 10 - Coach - Reserved ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit Test Scenario #4 The user reserves 3 seats in Coach (seat #5, seat #6, seat #7). The user cancels the reservation for seat #6. A seating chart is displayed. The user reserves 2 seats in Coach (seat #6, seat #8). The user cancels seat #5. A seating chart is displayed. Then the user quits. Note: blank lines are not counted. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! Coach seat 5 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! Coach seat 6 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach User chooses “Display a seating chart.” User chooses “Quit.” User chooses “Make a reservation,” then “Coach.” User chooses “Make a reservation,” then “Coach.” User chooses “Make a reservation,” then “Coach.” Page 13 of 16 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 ***** Reservation Result ***** Reservation successful! Coach seat 7 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Cancel Seat ***** Enter the seat number to cancel: ***** Cancelation Result ***** Cancelation successful. Seat number 6 has been canceled. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Seating Chart ***** Seat 1 - First Class - Empty Seat 2 - First Class - Empty Seat 3 - First Class - Empty Seat 4 - First Class - Empty Seat 5 - Coach - Reserved Seat 6 - Coach - Empty Seat 7 - Coach - Reserved Seat 8 - Coach - Empty Seat 9 - Coach - Empty Seat 10 - Coach - Empty ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! Coach seat 6 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! Coach seat 8 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit” ***** Cancel Seat ***** Enter the seat number to cancel: User chooses “Make a reservation,” then “Coach.” User chooses “Display a seating chart,” User chooses “Make a reservation,” then “Coach.” User chooses “Cancel a reservation,” then enters “5.” P Page 15 of 16 Test Scenario #5 The attempts to cancel a seat that hasn’t been reserved (seat #1). The user reserves 2 first class seats and 2 coach seats. The user attempts to cancel seat #3, seat #0, and seat #11, all of which are invalid. Then the user quits. Note: blank lines are not counted. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Cancel Seat ***** Enter the seat number to cancel: ***** Cancelation Result ***** Cancelation unsuccessful. The seat is empty or the seat number is invalid. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! First Class seat 1 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! First Class seat 2 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! Coach seat 5 is reserved. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Reserve Seat ***** Choose seat class: First Class * Coach ***** Reservation Result ***** Reservation successful! Coach seat 6 is reserved. User chooses “Cancel a reservation,” then enters “1”. User chooses “Make a reservation,” then “First Class.” User chooses “Make a reservation,” then “First Class.” User chooses “Make a reservation,” then “Coach.” User chooses “Make a reservation,” then “Coach.” Page 16 of 16 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Cancel Seat ***** Enter the seat number to cancel: ***** Cancelation Result ***** Cancelation unsuccessful. The seat is empty or the seat number is invalid. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Cancel Seat ***** Enter the seat number to cancel: ***** Cancelation Result ***** Cancelation unsuccessful. The seat is empty or the seat number is invalid. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit ***** Cancel Seat ***** Enter the seat number to cancel: ***** Cancelation Result ***** Cancelation unsuccessful. The seat is empty or the seat number is invalid. ***** CSC 120 Airlines Main Menu ***** What would you like to do? Make a reservation * Cancel a reservation * Display a seating chart * Quit User chooses “Cancel a reservation,” then enters “3”. User chooses “Cancel a reservation,” then enters “0”. User chooses “Cancel a reservation,” then enters “11”. User chooses “Quit”

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

package proj6;

public class Airplane {
    private Seat [] seats;// array of 10 items

    /**
    * default constructor
    */
    public Airplane() {
       seats = new Seat[10];
       int i;
       for ( i = 0; i < 4; i++) {
            seats[i] = new Seat(true, i + 1);
       }
       for (; i < 10; i++) {
            seats[i] = new Seat(false, i + 1);
       }
    }
   
    /**
    * reverse a seat based on its type
    * @param type true is first class, false is coach
    * @return number of the reserved seat
    *          -1 if cannot reserve any seat
    */
    public int reverse(boolean type){      
      
       Seat seat ;
       for (int i = 0; i < seats.length; i++) {
            seat = seats[i];
            if (seat.getBooleanType() == type &&
                   seat.isEmpty()) {...
$90.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats