In this assignment, you will develop a Flight-Ticket Management application that can help you search for a ticket that s
Posted: Thu May 05, 2022 1:12 pm
In this assignment, you will develop a Flight-Ticket Management
application that can help you search for a ticket that suits you.
The identification of a flight-ticket will be based on the key
produced by the combination of the company name and flight number.
Information of flight-tickets is to be inserted/read from either
the interface of your application or from an input text file. The
application should support deletion of a ticket record in addition
to other management features that are highlighted in the following
section. Each record is provided in ASCII format and spans at most
one line of text. The user interface should allow a user to
navigate and perform all the tasks/features listed in the following
section. You are supposed to create a program utilizing the
object-oriented programming (OOP) principles and appropriate data
structures discussed in class. You are required to use Hash Table
as the primary data structure to implement the application. Use
separate chaining to handle collisions. You should
implement all the data structures manually, STL based containers
are not allowed to be used here.
3 Implementation CSV File Format: The flight-ticket record consists of the following fields: companyName, flightNumber, country_of_origin, country_of_destination, stopover, price, time_of_departure, time_of_arrival, date Ex.: Emirates Sky Cargo, 1, Lebanon, USA, 3, 800, 11:50, 14:15,1-Apr Examples of flights records: Emirates Sky Cargo,1,Lebanon, USA,3,800, 11:50,14:15,1-Apr Aeromexico, 70, Bahrain, Luxembourg,1,1328,0:04,3:16,16-Dec Gol Transportes Aéreos, 103, Sweden, Lebanon,3,1387,12:58,12:26,26-Aug Boliviana de Aviación, 43, Belarus, Cyprus, 0,1157,23:02,0:07,9-Aug Aeromexico,52, Mongolia, United States,3,685,3:34,21:27,24-Feb Conviasa, 75,Canada, Hungary, 3,1411,1:02,18:24,21-Feb User Interface: Through its prompt, the program is expected to accept several commands that we outline next; these commands accept as operand a string that provides a flight-ticket's data, or the combination of companyName and flightNumber used as the key to look up records. The application interacts with the user using a command line (terminal based) interface as shown below: import <path> export <path> count_collisions :Import flight-tickets from a CSV file :Export flight-tickets to a CSV file :Print Number of Collisions add :Add a new flight-ticket :Delete a flight-ticket delete <key> find <key> allinday <date> :Find a flight-ticket's details printASC <key> exit :Display all flight-tickets in a day :Print flight-tickets in ascending order :Exit the program
The application, after performing the user's desired operation, presents the menu again for the next operation to be performed. NOTE: Make sure to handle the cases of the input keys provided by the user, for example you can use the tolower() function. Moreover, the below screenshots are just examples for showing you samples of inputs and outputs, so you may have different results when executing your own code. Features to Implement: 1. import <path> o Imports a CSV file >import Users/usr/Desktop/flights.csv o Invokes a function with the following 12 header: int importCSV (string path) o This function takes the path as an argument and loads all the flight-tickets from the CSV file into the Hash Table. The function either returns the number of flight-tickets read from the file as integer or returns -1, if a bad path is provided. 2. export <path> >export Users/usr/Desktop/flights2.csv 11 o Exports a CSV file o Invokes a function with the following header: int exportCSV (string path) This function takes the path as an argument and writes all the flight-tickets from the Hash Table to a CSV file. The function either returns the number of flight-tickets written to the file as integer or returns -1, if file cannot be created > count_collisions Total Number of Collisions is 20 3. count_collisions o Returns the number of collisions caused by a hash function. o Invokes a function with the following header: int count_collisions () o This function doesn't accept any parameters. It should operate based on the existing hash table. This method returns the number of collisions in the hash table. 4. add o Adds a new flight record. If the element already exists, no entry will be added, but a warning message will be issued stating that the record already exists the system. o Invokes a function with the following header: int add (FlightInfo *data) This function takes a pointer to a FlightInfo object as an argument. The function returns 1 if the record has been successfully added or -1 otherwise.
> add Please enter the details if the flght-ticket: Company Name: Emirates Sky Cargo Flight Number: 1 Country of Origin: Lebanon Country of Destination: USA Stopover: 3 Price: 800 Time of Departure: 11:50 Time of Arrival: 14:15 Date: 1-Apr Flight-ticket has been successfully added !! 5. delete <companyName,flightNumber> o Deletes a flight-ticket record based on the entered key <companyName,flightNumber>. If no such entry exists, a warning message to the standard error is printed out. Invokes a function with the following header: o void removeRecord (string companyName, int flightNumber) This function takes a key (i.e., company Name and flightNumber) as argument. It prints confirmation message if the record has been successfully added or failure message otherwise. > delete Air Canada, 2 2 records found: 1. Air Canada, 2, Sao Tome and Principe, Tonga, 0,716, 18:01, 2:29, 8-Jul 2. Air Canada, 2, Tunisia, Estonia,2,1723,2:58,6:53,30-Aug Please select the record you want to delete: 1 The flight-ticket record has been successfully deleted! 6. find <companyName,flightNumber> Searches for a flight-ticket record of the entered key <companyName,flightNumber>. Invokes a function with the following header: void find (string company Name, int flight Number) o This function takes a key (i.e., companyName and flightNumber) as an argument and displays the entire records that match the entered key or displays "Not Found!" message otherwise. It also prints out the actual time taken by the find execution.
7. allinday <date> o Searches for all the Flight-tickets for a specified date. o Invokes a function with the following header: void allinday (string date) o This function takes a specific date as an argument and prints out all the flight-tickets available for that date or display "Not Found!" message otherwise. > allinday 2-Apr 4 records found: 1. Alaska Airlines, 20, Bangladesh, Djibouti,3,1933, 14:15,18:20,2-Apr 2. Aerolineas Argentinas Airlines, 3, Andorra, Tajikistan, 0,1351, 15:06, 13:30,2-Apr 3. Azul Brazilian Airlines, 66, United Arab Emirates, Ghana, 2,1790, 16:23,15:10,2-Apr 4. Conviasa,19, Costa Rica, Bulgaria,1,445,24:10:00,20:37,2-Apr 8. printASC <companyName,flightNumber> o Displays in an ascending order (based on the flight destination country) all flight-tickets having the same key entered by the user <companyName,flightNumber>. Invokes a function with the following header: o void printASC (string companyName, int flightNumber) > printAsc Air Canada, 5 Air Canada, 5, Hungary, Bahamas, 0,823,4:59, 11:55,16-Mar Air Canada, 5, Barbados, Colombia, 2,234,9:14, 18:12,27-Mar Air Canada,5, Singapore, Faroe Islands, 2,703,6:48,5:53,1-Jun Air Canada, 5, Tunisia, Senegal,3,349,4:25,6:34, 15-Jan Air Canada, 5, Liechtenstein, Svalbard and Jan Mayen, 3,740,8:01,11:25,9-May o Exits the program 9. exit
application that can help you search for a ticket that suits you.
The identification of a flight-ticket will be based on the key
produced by the combination of the company name and flight number.
Information of flight-tickets is to be inserted/read from either
the interface of your application or from an input text file. The
application should support deletion of a ticket record in addition
to other management features that are highlighted in the following
section. Each record is provided in ASCII format and spans at most
one line of text. The user interface should allow a user to
navigate and perform all the tasks/features listed in the following
section. You are supposed to create a program utilizing the
object-oriented programming (OOP) principles and appropriate data
structures discussed in class. You are required to use Hash Table
as the primary data structure to implement the application. Use
separate chaining to handle collisions. You should
implement all the data structures manually, STL based containers
are not allowed to be used here.
3 Implementation CSV File Format: The flight-ticket record consists of the following fields: companyName, flightNumber, country_of_origin, country_of_destination, stopover, price, time_of_departure, time_of_arrival, date Ex.: Emirates Sky Cargo, 1, Lebanon, USA, 3, 800, 11:50, 14:15,1-Apr Examples of flights records: Emirates Sky Cargo,1,Lebanon, USA,3,800, 11:50,14:15,1-Apr Aeromexico, 70, Bahrain, Luxembourg,1,1328,0:04,3:16,16-Dec Gol Transportes Aéreos, 103, Sweden, Lebanon,3,1387,12:58,12:26,26-Aug Boliviana de Aviación, 43, Belarus, Cyprus, 0,1157,23:02,0:07,9-Aug Aeromexico,52, Mongolia, United States,3,685,3:34,21:27,24-Feb Conviasa, 75,Canada, Hungary, 3,1411,1:02,18:24,21-Feb User Interface: Through its prompt, the program is expected to accept several commands that we outline next; these commands accept as operand a string that provides a flight-ticket's data, or the combination of companyName and flightNumber used as the key to look up records. The application interacts with the user using a command line (terminal based) interface as shown below: import <path> export <path> count_collisions :Import flight-tickets from a CSV file :Export flight-tickets to a CSV file :Print Number of Collisions add :Add a new flight-ticket :Delete a flight-ticket delete <key> find <key> allinday <date> :Find a flight-ticket's details printASC <key> exit :Display all flight-tickets in a day :Print flight-tickets in ascending order :Exit the program
The application, after performing the user's desired operation, presents the menu again for the next operation to be performed. NOTE: Make sure to handle the cases of the input keys provided by the user, for example you can use the tolower() function. Moreover, the below screenshots are just examples for showing you samples of inputs and outputs, so you may have different results when executing your own code. Features to Implement: 1. import <path> o Imports a CSV file >import Users/usr/Desktop/flights.csv o Invokes a function with the following 12 header: int importCSV (string path) o This function takes the path as an argument and loads all the flight-tickets from the CSV file into the Hash Table. The function either returns the number of flight-tickets read from the file as integer or returns -1, if a bad path is provided. 2. export <path> >export Users/usr/Desktop/flights2.csv 11 o Exports a CSV file o Invokes a function with the following header: int exportCSV (string path) This function takes the path as an argument and writes all the flight-tickets from the Hash Table to a CSV file. The function either returns the number of flight-tickets written to the file as integer or returns -1, if file cannot be created > count_collisions Total Number of Collisions is 20 3. count_collisions o Returns the number of collisions caused by a hash function. o Invokes a function with the following header: int count_collisions () o This function doesn't accept any parameters. It should operate based on the existing hash table. This method returns the number of collisions in the hash table. 4. add o Adds a new flight record. If the element already exists, no entry will be added, but a warning message will be issued stating that the record already exists the system. o Invokes a function with the following header: int add (FlightInfo *data) This function takes a pointer to a FlightInfo object as an argument. The function returns 1 if the record has been successfully added or -1 otherwise.
> add Please enter the details if the flght-ticket: Company Name: Emirates Sky Cargo Flight Number: 1 Country of Origin: Lebanon Country of Destination: USA Stopover: 3 Price: 800 Time of Departure: 11:50 Time of Arrival: 14:15 Date: 1-Apr Flight-ticket has been successfully added !! 5. delete <companyName,flightNumber> o Deletes a flight-ticket record based on the entered key <companyName,flightNumber>. If no such entry exists, a warning message to the standard error is printed out. Invokes a function with the following header: o void removeRecord (string companyName, int flightNumber) This function takes a key (i.e., company Name and flightNumber) as argument. It prints confirmation message if the record has been successfully added or failure message otherwise. > delete Air Canada, 2 2 records found: 1. Air Canada, 2, Sao Tome and Principe, Tonga, 0,716, 18:01, 2:29, 8-Jul 2. Air Canada, 2, Tunisia, Estonia,2,1723,2:58,6:53,30-Aug Please select the record you want to delete: 1 The flight-ticket record has been successfully deleted! 6. find <companyName,flightNumber> Searches for a flight-ticket record of the entered key <companyName,flightNumber>. Invokes a function with the following header: void find (string company Name, int flight Number) o This function takes a key (i.e., companyName and flightNumber) as an argument and displays the entire records that match the entered key or displays "Not Found!" message otherwise. It also prints out the actual time taken by the find execution.
7. allinday <date> o Searches for all the Flight-tickets for a specified date. o Invokes a function with the following header: void allinday (string date) o This function takes a specific date as an argument and prints out all the flight-tickets available for that date or display "Not Found!" message otherwise. > allinday 2-Apr 4 records found: 1. Alaska Airlines, 20, Bangladesh, Djibouti,3,1933, 14:15,18:20,2-Apr 2. Aerolineas Argentinas Airlines, 3, Andorra, Tajikistan, 0,1351, 15:06, 13:30,2-Apr 3. Azul Brazilian Airlines, 66, United Arab Emirates, Ghana, 2,1790, 16:23,15:10,2-Apr 4. Conviasa,19, Costa Rica, Bulgaria,1,445,24:10:00,20:37,2-Apr 8. printASC <companyName,flightNumber> o Displays in an ascending order (based on the flight destination country) all flight-tickets having the same key entered by the user <companyName,flightNumber>. Invokes a function with the following header: o void printASC (string companyName, int flightNumber) > printAsc Air Canada, 5 Air Canada, 5, Hungary, Bahamas, 0,823,4:59, 11:55,16-Mar Air Canada, 5, Barbados, Colombia, 2,234,9:14, 18:12,27-Mar Air Canada,5, Singapore, Faroe Islands, 2,703,6:48,5:53,1-Jun Air Canada, 5, Tunisia, Senegal,3,349,4:25,6:34, 15-Jan Air Canada, 5, Liechtenstein, Svalbard and Jan Mayen, 3,740,8:01,11:25,9-May o Exits the program 9. exit