Question: This problem is Java The Problem: A common task in computing is to take data and apply changes (called transactions ) to the data, then

This problem is Java

The Problem:

A common task in computing is to take data and apply changes (called transactions) to the data, then saving the updated data. This is the type of program you will write.

You will read a file of flight reservation data to be loaded into an array with a max size of 20. A second file will hold the transactions that will be applied to the data that has been stored in the array. At the end of the program, the updated data in the array will be written to a third file.

Flight class

This class will hold the information about a flight. It is responsible for the following data: flight number, flight date, departure airport, arrival airport, departure time, arrival time, and seat assignment. The date will be in the form mm/dd/yyyy. The time will be in the form hh:mm PM. This class should include a default constructor and another constructor that will receive data for all of the instance variables. Also include toString and equals methods. The toString needs to format the data in the form that is needed for output written to the screen in an itinerary. Two Flight classes are considered equal when they have the same flightNumber and flightDate.

Reservation class

This class holds all of the information about a reservation for one person. It will include the passengers name (one variable to hold first and last names), reservation number, departure flight and return flight (the flights are objects of the Flight class). Constructors should include a default constructor and another one that accepts values for all of the instance variables. Also include toString and equals methods. The toString needs to format the data in the format of output written to the screen in an itinerary. Reservations are considered to be equal when they have the same reservation number.

Airline class

This class is responsible for holding the array of reservations and all of the methods to process the transactions. Transactions are represented in the file with a numeric code as follows:

Code

Transaction

1

Add a reservation all data will be the same format as the reservations that are loaded into the array at the beginning of the program.

2

Print the itinerary of one passenger Printed to the screen

3

Print the itineraries of all of the reservations Printed to the screen

4

Write list to file Writes all of the updated reservations in the list to a file

AirlineInput class

There are two input files. The first file, AirlineData.txt, holds all of the existing reservations. This should be read at the beginning of the program and stored in an array. The second file, Transactions.txt, has the transaction codes and data that is associated with each code.

AirlineData.txt format

Transactions.txt format.

Note: each type of transaction requires different input. The code will be followed by the data required for that code. There will be a code and data in one of the following formats.

Transaction code 1

< reservation number>

Transaction code 2

Transaction code 3

Transaction code 4

AirlineOutput class

This class will be responsible for:

Code 2 Displaying the itinerary for one passenger

Sample output:

Passenger Name: Carl Foreman

Reservation Number: 1234

DepartureFlight:

Flight Number: UA1235

Flight Date: June 23, 2014

Departure Airport: null

Arrival Airport: null

Departure Time: 4:00 PM

Arrival Time: 7:15 PM

Seat: 23A

Return Flight:

Flight Number: UA673

Flight Date: July 12, 2014

Departure Airport: null

Arrival Airport: null

Departure Time: 10:00 AM

Arrival Time: 11:25 AM

Seat: 8A

Note that the date has been changed from the form 04/16/2014 to the form April 16, 2014

Code 3 Displaying the itineraries for all reservations

This displays the itinerary for each person in the same format as above.

Leave a blank line between each itinerary.

Code 4 Writing the contents of the array to the fileThis should be in the same format as the input file AirlineData.txt

The data can be left in the format used to display to the screen.

Transactions.txt

1 John Miller 1234 UA1235 06/12/2014 ORD LGA 4:00 PM 7:15 PM 30F UA673 06/19/2014 LGA ORD 10:00 AM 11:25 AM 10E 3 1 Bob Barker 8497 UA317 08/04/2014 ORD SFO 8:10 AM 10:45 AM 12A UA728 08/14/2014 SFO ORD 12:52 PM 7:03 PM 18A 2 1235 2 8976 3 4

AirlineData.txt

Carl Foreman 1234 UA1235 06/23/2014 ORD LGA 4:00 PM 7:15 PM 23A UA673 07/12/2014 LGA ORD 10:00 AM 11:25 AM 8A Jennifer Foreman 1235 UA1235 06/23/2014 ORD LGA 4:00 PM 7:15 PM 23B UA673 07/12/2014 LGA ORD 10:00 AM 11:25 AM 8B Jane Anderson 4577 UA317 08/04/2014 ORD SFO 8:10 AM 10:45 AM 11C UA728 08/14/2014 SFO ORD 12:52 PM 7:03 PM 10D Jason Anderson 4578 UA317 08/04/2014 ORD SFO 8:10 AM 10:45 AM 11D UA728 08/14/2014 SFO ORD 12:52 PM 7:03 PM 10C Kimberly Jones 8975 UA605 04/20/2014 ORD DEN 10:00 AM 11:39 AM 25D UA830 4/29/2014 DEN ORD 3:39 PM 7:08 PM 30C Doug Jones 8976 UA605 04/20/2014 ORD DEN 10:00 AM 11:39 AM 25E UA830 04/29/2014 DEN ORD 3:39 PM 7:08 PM 30D 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!