Write a java blueprint class that models an Airline Reservation and adheres to the following criteria: 4
Fantastic news! We've Found the answer you've been seeking!
Question:
Write a java blueprint class that models an Airline Reservation and adheres to the following criteria:
- 4 instance variables: first name, last name, flight number, seat number , ticket number
- A default constructor
- A constructor that takes five arguments
- A setter and getter for each field that simply sets and gets the field value.
- A method called "retrieveSeatingClass" which returns a "seating class" for each seat number (use a switch statement)
- seats 1-2: First Class
- seats 3-4: Second Class
- seats 5-6 Third Class
- seats 7-8: Fourth Class
Challenge 2
- Write a method called "checkNoFlyList" which concatenates the first and last name then checks the name against a "nofly list " which contains three names: Jack Blue, Jack Green and Jill White. If the name matches (regardless of case differences) the method will return the code "9999".
Challenge 3
- Write a method called "segmentState" which will concatenate all object state into one string, then will return a portion of that string based upon the first and last number of the passengers ticket number. We will assume that the first number is smaller than the last number and that the last number is no greater than the total number of characters in the concatenated string. (Do not test for this just assume it will be the case) .
For example, let's assume the following:
first name - Peter
last name - Smith
flight number - 346
seat number - 8
ticket number -45612857
the fully concatenated string would be: "PeterSmith346845612857"
the return value of the method for this example would be: "erSm", where "e" is the 4th character and "m" is the 7th character.
Challenge 4
- Create a second class called AirlineReservationTestHarness, which contains a main method, to test the first class:
- Note: Any interaction with the user must be accompanied with an appropriate message.
- Instantiate an AirlineReservation object and pre-populate the four fields with random data you make up.
- Print out the object state on separate lines.
- Print out the object state as a single string, including the seating class and a portion of that string based upon the first and last number of the ticket number.
- If the passenger is on the no fly list print the word "ALERT" on the screen 7 times, with each word appearing on the screen approximately every second. DO NOT USE A THREAD TO DO THIS , think of a hack way to use what we have learned in lectures 1-5.
- Instantiate a second AirlineReservation object with no data.
- Ask the user for the data required to fill each field of the record.
- Print out the object state on separate lines.
- Print out the object state as a single string, including the seating class and a portion of that string based upon the first and last number of the ticket number.
- Note: Any interaction with the user must be accompanied with an appropriate message.
Related Book For
Concepts of Database Management
ISBN: 978-1285427102
8th edition
Authors: Philip J. Pratt, Mary Z. Last
Posted Date: