Airline reservation system using your own container implementations
Due: 6 Feb 2008
Educational objectives: Experience implementing a self-organizing linked list and a simple vector class, solving problems using the above classes, and implementing and using templates.
Statement of work: (i) Implement a linked list class that self-organizes as specified below and (ii) a templated vector class. (iii) Develop a simple airline reservation software, as in assignment 1, but using the containers you implemented, instead of using STL containers. Note: All reservation records should be in a single linked list.
Deliverables: Turn in a
makefile
and all header (*.h) and cpp (*.cpp) files that are needed to build your software. Turn in your development log too, which should be a plain ASCII text file calledLOG.txt
in your project directory. You will submit all of these as described in www.cs.fsu.edu/~asriniva/courses/DS08/HWinstructions.html.Requirements:
- Create a subdirectory called
proj2
.- You will need to have a
makefile
in this directory. In addition, all the header and cpp files needed to build your software must be present here, as well as theLOG.txt
file.- You should implement appropriate classes for the software. Your code should be well designed and object oriented.
- You should implement a templated
Vector
class in the file Vector.h (note the capitalization of the first letter inVector
). The following features must be implemented:(i) a default constructor that initializes an array of size 2, (ii) a destructor, (iii) void push_back(const T &e), (iv) the operator[], and (v) int size( ) const. You may implement additional features, if you wish to. If you do not implement a copy constructor and an assignment operator, then you should prevent their use by making them private.- You should implement a doubly-linked list class that self-organizes as described below. This class need not be generic; it is sufficient to implement it so that it can store the reservation records. You are free to choose the specific features you wish to implement, but they should be reasonable. For example, you will certainly need to implement a method that lets you add records into the list.
- Your software keeps track of reservation records in a linked list object, of the type you implemented above. Each record consists of the following fields: (i) Name, (ii) Phone number, (iii) Flight number, and (iv) Date of travel. The user will enter Name in the following format:
FirstName space [middle initials, if applicable, with a period after each initial] space LastName
.The user will enter Phone number as a sequence of digits, with possibly, spaces, hyphens, and parentheses. All these, except the digits, should be ignored. That is, the number850-644-1234
is equivalent to the number(850) 644 1234
. The user will enter the flight number as a sequence of alphanumeric characters, without whitespace between them. The user will enter the travel date in one of the following forms:mmddyyyy
ormmddyy
. All user input can be considered to be syntactically correct. The user is provided the ability to perform the operations given below.- The software is run by the user on the command line, as follows:
- Reservations Filename
- The software reads a list of flights and the number of seats in them from
Filename
(which contains a flight number followed by the number of seats, on each line), stores the information in an object of the vector class you implemented, and then repeats the following:
- It presents a prompt of the following form: Reservations>>
- It accepts commands typed by the user (each command is terminated by a newline). Any leading whitespace (before the command) is ignored.
- It performs an operation, as desired by the user's command. This operation may include an output. All output should be on a new line, and should terminate with a single newline character. You should not output anything other than those specified below.
- The complete set of commands accepted by your program are as follows.
new flight <flight-number> <seats>
- where <flight-number> is the flight number of a new flight to be added, and <seats> is the number of seats in that flight. If a flight with that name already exists, then you should output the following: A flight numbered <number> already exists. Flight not created.
quit
- This causes the program to terminate after de-allocating all memory that was allocated.
add (<name>, <phone-number>, <flight-number>, <date>)
- This creates a new reservation record if a seat is available, and adds it to the end of the linked list. If an identical record exists, then you should output: This reservation already exists. Otherwise, if a seat is not available, then you should output: No seat available. If there is no flight numbered <flight-number>, then output: No flight numbered <flight-number> exists.
delete <name> from <flight-number> on <date>
- Delete the corresponding record. If the record does not exit, then output: This reservation does not exist.
is <name> in <flight-number> on <date>?
- Output Yes if <name> has a reservation on the specified flight. Otherwise output No. This command also causes a self-organization operation, if the reservation exists. The self-organization should be performed using the count method, except that the record that is found is swapped with each predecessor only if its count exceeds that of its predecessor by at least two.
lookup <name>
- Lists all records for <name> in the order in which they appear in the linked list, in the following format: 1. (<name1>, <phone-number1>, <flight-number1>, <date1>), 2. (<name2>, <phone-number2>, <flight-number2>, <date2>), ... . If a reservation with that name does not exist, then you should output: No reservation exists for <name>.
display <flight-number> on <date>
- Display each record in the specified flight in the order in which they appear in the linked list, in the following format: 1. (<name1>, <phone-number1>, <flight-number1>, <date1>), 2. (<name2>, <phone-number2>, <flight-number2>, <date2>), ... . If no record exists for that flight, then output: No reservation exists for this flight. If there is no flight numbered <flight-number>, then output: No flight numbered <flight-number> exists.
Sample input file and executable: A sample executable is available at proj2, which will run on
linprog
. It runs correctly for the sample file FLIGHTS.txt (given on the command line), with the sample commands given in input. The first person to find errors in our program will get a bonus point!Bonus points (5):
You may get up to 5 additional points for significant extra work, such as implementing more features, or providing a GUI interface. Please obtain feedback from us prior to doing this. If you wish to get bonus points, then please submit your work as usual, but send an email to the TA. The TA will schedule a meeting with you, and you can demonstrate the special features of your software then.
Notes:
- Your program should not have any output other than those specified above.
- You should not use the STL
list
orvector
classes. You may use thestring
class. Please get my permission before using any other STL feature.- We will test your
Vector
class on an entirely different application. So it is important for this class to be generic and exactly as specified.
Last modified: 28 Jan 2008