For C++ Coding This one is like \"weird\" on how they are asking for the spec so
ID: 3727313 • Letter: F
Question
For C++ Coding
This one is like "weird" on how they are asking for the spec so any help would be helpfull!
Additonal Notes:
:No Linear Programming(Function Protoypes)
- Header files
-Main Just Starts the engine/program
- Below is the full spec i know it is confussing in some areas but that what was given.
Airline Reservation System
Overview
This program is to support the client-side of an airline reservation system for airline reservation agents. The program does not manage user accounts, it only shows status of the flights. It allows the reservation agent to perform basic functions such as book and cancel reservations, display information such as boarding passes and seat assignments on the flight.
NOTE: All data for flights, passengers, etc. should be read from a file at the start of the program. The program should only save data back to file when given a command by the user and when the program is exiting.
Detailed Description
The system should allow a user to perform the following functions:
Book a new reservation
Cancel a reservation
Display boarding pass for a passenger
Display flight schedule (sorted by any field)
Display available cities (sorted by name or code)
List passengers on a given flight and seat assignments (sorted by name or seat)
The airline has two types of aircraft. The type A plane irst has 5 rows. Each row has seats A, B, C, and D arranged as the following (The aisle is indicated with an X):
X
The second ptype of plane has 5 rows with seats A, B, and C in the following configuration:
The airline flies between the following cities:
The flight schedule is the same every day of the week. The following table contains the flight information to be used for reservations:
Frequent Flyer points
Your system must make sure that a flight is not overbook, and if a flight is booked it should suggest other flights to the same destination. The boarding pass should include the flight details including the seat number and the number of frequent flyer miles that can be earned.
Input
The input is all done via interactive data entry. You may use menus, commands, etc. The interface is your choice.
Output
Output is done to the screen, but the program should also save all data between execution using one or more files. This means that when the system restarts, the reservations that have been made should reload.
1A 1BX
1C 1D 2A 2B X 2C 2D 3A 3B X 3C 3D 4A 4B X 4C 4D 5A 5B X 5C 5DExplanation / Answer
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
class ReservationRecords
{
private:
struct Flights
{
string FlightNumber;
int TotalSeats;
int TakenSeats;
};
struct Record
{
string Name;
string PhoneNumber;
string FlightNumber;
string DateOfTravel;
};
vector<Flights> FlightList;
vector<Record> RecordList;
public:
// add all info into flightlist
void GetFlightData() {
string filename;
cout << "Reservations>> ";
cin >> filename;
ifstream inputfile (filename); // ifstream = stream class to read from files
if (inputfile.is_open())
cout << "Flight numbers and seat availability uploaded ";
else
cout << "ERROR: cannot open input file. ";
// reading in flight number and seat capacity from "filename"
string FilenameFlightNumber;
int FilenameTotalSeats;
while (!inputfile.eof()) {// While not at end of inputfile
inputfile >> FilenameFlightNumber;
inputfile >> FilenameTotalSeats;
Flights AddToList;
AddToList.FlightNumber = FilenameFlightNumber;
AddToList.TotalSeats = FilenameTotalSeats;
FlightList.push_back(AddToList);
};
};
void NewFlight(string NewFlightNumber, int NewFlightTotalSeats) {
for(int i =0; i<FlightList.size(); i++)
{
if(NewFlightNumber.compare(FlightList[i].FlightNumber)) // compare compares if equal
{
cout << "A flight numbered " << NewFlightNumber << " already exists. Flight not created. ";
return;
}
}
Flights AddToList;
AddToList.FlightNumber = NewFlightNumber;
AddToList.TotalSeats = NewFlightTotalSeats;
FlightList.push_back(AddToList);
};
void add(string AddName, string AddPhoneNumber, string AddFlightNumber, string AddDate) {
// go through passenger list to check name and make sure reservation does not exist
// go through flight and when find flight list check if seats are available. If nothing found, print "no flight exists"
// otherwise, add object to passenger list
for(int i=0; i<RecordList.size(); i++)
{
if(AddName.compare(RecordList[i].Name) && AddFlightNumber.compare(RecordList[i].FlightNumber) && AddDate.compare(RecordList[i].DateOfTravel))
{
cout << "This reservation already exists. ";
return;
}
else if(AddFlightNumber.compare(RecordList[i].FlightNumber))
{ // we found the flight
// check if seats are available
int j;
for (j = 0; j < FlightList.size(); j++)
if (RecordList[i].FlightNumber == FlightList[j].FlightNumber)
if (FlightList[j].TotalSeats == FlightList[j].TakenSeats)
{
cout << "No seat available. ";
return;
}
// seats are available and we can the record
Record AddToList;
AddToList.Name = AddName;
AddToList.PhoneNumber = AddPhoneNumber;
AddToList.FlightNumber = AddFlightNumber;
AddToList.DateOfTravel = AddDate;
RecordList.push_back(AddToList);
FlightList[j].TakenSeats++;
return;
}
}
// exit the loop
// we have not found a flight number
cout << "No flight numbered " << AddFlightNumber << " exists. ";
};
// Delete record and subtract 1 from taken seats of that specific flight number.
// If record.name does not exist, print "This reservation does not exist."
void Delete(string DeleteName, string DeleteFlightNumber, string DeleteDate) {
for(int i=0; i<RecordList.size(); i++)
{
if(DeleteName.compare(RecordList[i].Name) && DeleteFlightNumber.compare(RecordList[i].FlightNumber) && DeleteDate.compare(RecordList[i].DateOfTravel))
{
// Delete record [i] and subtract 1 from Flights.TakenSeats
RecordList[i] = NULL;
FlightList[i].TakenSeats--;
return;
}
}
cout << "This reservation does not exist ";
};
};
int main()
{
// call build flight list
};
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.