Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 10 PostLab CS1440 Overview To tie everything all together, we will now complete the TicketKiosk class. The TicketKiosk class reads and prints the

imageimageimageimageimage

Lab 10 PostLab CS1440 Overview To tie everything all together, we will now complete the TicketKiosk class. The TicketKiosk class reads and prints the schedule and manages input and output to and from the user. The schedule information is stored in a file named Flight Info.txt. Do not change FlightInfo.txt. Opening and using this file is part of the readSchedule method, which you must complete in the postLab. Activities 1. Copy FlightInfo.txt files into your project directory. You cannot simply drop Flight Info.txt into your BlueJ window. You must copy it into the project folder instead. Do not change the Flight Info.txt file. This file contains the flight schedule information. 2. Complete the method readOneFlight. It should read one set of flight data from the Flight Info.txt file. NOTE: You are given a Scanner object as a parameter that already has the file open. Use it. NOTE: Do not attempt to read the entire file (i.e., don't use a loop). Simply read the next five data items one by one. NOTE: Do not try to open the text file. It has already been opened. NOTE: You will have to insert an extra inFile.nextLine() somewhere in your method to correctly read mixed data (i.e., data of both String types and numeric types). To complete readoOneFlight, (a) Read the flight number using the Scanner object. (b) Read the pilot information as follows: Read the name using the Scanner object. Read the license number using the Scanner object. Create a new Pilot object from the above two pieces of information. (c) Read the date using the Scanner object. (d) Read the destination using the Scanner object. (e) Create a new Flight object with the data you have read in and return it. 3. If you do so working correctly and have created your Flight class correctly, you should be able to run print Schedule and see a schedule very close to the following: Flt#: 885 Dest Boston Plt: Bill Jones Date: 06/21/14 Flt#: 885 Flt#: 602 Flt#: 212 Flt#: 650 Flt#: 111 Dest: Boston Dest: London Dest: Berlin Dest: Chicago Dest: New York Plt: Bill Jones Plt: Tim Jones Plt: Tim Jones Plt: Tim Jones Flt#: 190 Dest: Tokyo Plt: Bill Jones Plt: Tim Jones Date: 06/21/14 Date: 06/21/14 Date: 06/24/14 Date: 06/26/14 Date: 06/26/14 Date: 06/28/14 4. Complete the purchaseTickets method. Always prompt your user for any input. Use prompts exactly as shown in the "Finished Ticket Kiosk usage example" at the end of this document. Use println for all prompts. Do not use print or you will get errors. The purchaseTickets method should: (a) Print the schedule using printSchedule. (b) Read a name from the user. (c) If the name is not the word exit, then i. Read a social security number from the user. ii. Create a Customer object using the above data. iii. Read a flight number from the user. iv. Look up the flight using the flight number with the findFlight method as follows: Flight flight = find Flight (flight Number); (You can read about findFlight in the method javadoc.) v. If the flight is not null (which means the user entered a valid flight number), then A. Create a new Ticket object using the customer and flight information from steps ii and iv above A. Create a new Ticket object using the customer and flight information from steps ii and iv above. B. Print the Ticket object. Print a blank line before and after the ticket. Otherwise, if the flight is null (i.e., if the user entered a bad flight number), then A. Print an error message. B. Wait for user to acknowledge the error by hitting enter. You can accomplish this by adding an extra call to keyboard.nextLine(). (d) Repeat steps a, b, and c until the user types the word exit for the name. (e) Print a goodbye message. 5. Assuming everything in all classes is correct, you should be able to run the main method and operate the kiosk software. After the UML diagrams below is a sample run of a working kiosk titled "Finished Ticket Kiosk Usage Example". Items the user typed in are in red. If you type exactly the red text at exactly the same places the output on your screen should look exactly like the output on the sample below. If it does not match line for line, you will fail the tests. Make your output conform exactly to the sample before continuing. Red text is user input. Blue text is simply pointing out where the pause should occur on an error. 6. Copy TestTicketKiosk1. java and TestTicketKiosk2. java files into your project and clear all errors. 7. Make sure the project conforms to Checkstyle with no errors. 8. Submit your project to Web-CAT. You may upload it to AsULearn for a backup, but you will earn a grade of 0 if your project is not uploaded on Web-CAT as well. Finished Ticket Kiosk Usage Example Red text is user input. Blue text is where the program pauses. The line numbers are for reference only. 1: 2: Flt#: 885 3: Flt#: 602 4: Flt#: 212 5: Flt#: 650 6: Flt#: 111 7: Flt#: 190 8: Dest: Boston Dest: London Dest: Berlin Dest: Chicago Dest: New York Dest: Tokyo Plt: Bill Jones Plt: Tim Jones Plt: Tim Jones Plt: Tim Jones Plt: Bill Jones Plt: Tim Jones Date: 06/21/14 Date: 06/21/14 Date: 06/24/14 Date: 06/26/14 Date: 06/26/14 Date: 06/28/14 9: Enter your name (or type exit): 10: Al Bundy 11: Enter your social security number: 12: 222-22-2222 13: Enter your flight number: 14: 885 15: 16: ******** TICKET 17: Name: Al Bundy 18: SSN: 222-22-2222 19: Flight: 885 20: Date: 06/21/14 21: Destination: Boston 22: 23: 24: 25: Flt#: 885 26: Flt#: 602 27 Flt#: 212 28: Flt#: 650 29: Flt#: 111 30: Flt#: 190 31: Dest: Boston Dest London Dest: Berlin Dest: Chicago Dest: New York Dest: Tokyo Plt: Bill Jones Plt: Tim Jones Plt: Tim Jones Plt: Tim Jones Plt: Bill Jones Plt: Tim Jones Date: 06/21/14 Date: 06/21/14 Date: 06/24/14 Date: 06/26/14 Date: 06/26/14 32: Enter your name (or type exit): 33: Peg Bundy 34: Enter your social security number: 35: 111-11-1111 36: Enter your flight number: 37: 100 38: Bad flight number 38: Hit enter to continue. Date: 06/28/14 38: Hit enter to continue. Extra keyboard.nextLine() to pause here. 40: 41: 42: Flt#: 885 43: Flt#: 602 44: Flt#: 212 45: Flt#: 650 46: Flt#: 111 47 Flt#: 190 48: Dest: Boston Dest: London Dest: Berlin Dest: Chicago Dest: New York Dest: Tokyo Plt: Bill Jones Plt: Tim Jones Plt: Tim Jones Plt: Tim Jones Plt: Bill Jones Plt: Tim Jones Date: 06/21/14 Date: 06/21/14 Date: 06/24/14 Date: 06/26/14 Date: 06/26/14 Date: 06/28/14 49: Enter your name (or type exit): 50: exit 51: Goodbye

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Im sorry but as an AI textbased model I dont have access to your project directory or the FlightInfo... 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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions