Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Portal {
- public:
- Portal() {}
- virtual ~Portal() {}
- enum SortField {Airline, Time, Duration, Price};
- enum SortOrder {Ascending, Descending};
- enum BuyOption {Cheapest, Fastest, Earliest, Latest};
- // initialize route information by reading in input file with government data/guidelines
- virtual void initRoutes(string routeInfo) {}
- // return constraints/guidelines for a given origin+destination combination
- virtual void routeInfo(string origin, string destination, float& dist, float& duration, float& minPrice, float& maxPrice, float& timeVariation) {}
- // display (to cout) the list of flights with available seats between origin and destination
- // List is to be shown in sorted order, based on sortField and sortOrder
- // sortField is one of the values of enum SortField
- // sortOrder is one of values of enum SortOrder
- virtual void showFlights(string origin, string destination, SortField sortField = Airline, SortOrder sortOrder = Descending) {}
- // purchase a ticket based on BuyOption criteria, optionally specifying a preferred airline
- // This will be for the last selected origin+destination combination
- virtual bool buyTicket(BuyOption cirteria, string airline = NULL) = 0;
- };
- class POR: public Portal{
- protected:
- vector<Route *> rt_list;
- public:
- void initRoutes(string routeInfo){
- int n=0;
- string line;
- float val;
- string str;
- ifstream rfile;
- rfile.open(routeInfo.c_str(),ios::in);
- if(rfile.is_open()){
- while(!rfile.eof()){
- getline(rfile,line);
- ++n;
- }
- }
- rfile.close();
- rfile.open(routeInfo.c_str(),ios::in);
- Route *ptr;
- while(!rfile.eof()){
- rfile >> str;
- ptr->setorigin(str);
- rfile >> str;
- ptr->setdestination(str);
- rfile >> val;
- ptr->setdistance(val);
- rfile >> val;
- ptr->setduration(val);
- rfile >> val;
- ptr->setminpkm(val);
- rfile >> val;
- ptr->setmaxpkm(val);
- rfile >> val;
- ptr->setdev(val);
- rt_list.push_back(ptr);
- }
- rfile.close();
- }
- void routeInfo(string origin, string destination, float& dist, float& duration,float& minPrice, float& maxPrice, float& timeVariation){
- int len = rt_list.size();
- string str1,str2;
- for(int i = 0;i < len;i++){
- str1 = rt_list[i]->getOrigin();
- str2 = rt_list[i]->getDestination();
- if((str1 == origin and str2 == destination) or (str1 == destination and str2 == origin)){
- cout<<rt_list[i]->getDistance();
- cout<<rt_list[i]->getDuration();
- cout<<rt_list[i]->getMinpkm() * rt_list[i]->getDistance();
- cout<<rt_list[i]->getMaxpkm() * rt_list[i]->getDistance();
- cout<<rt_list[i]->getDev();
- }
- }
- }
- void showFlights(string origin, string destination, SortField sortField = Airline,SortOrder sortOrder = Descending){
- }
- bool buyTicket(BuyOption cirteria, string airline = NULL){
- }
- };
- class Airline {
- private:
- Portal *portal;
- protected:
- Portal *getPortal() {
- return portal;
- }
- public:
- Airline(Portal *pl):portal(pl){
- }
- virtual ~Airline() {}
- // reads in the input file for the airline and initializes its
- // information about routes, capacity etc
- virtual void init(string ifile) = 0;
- virtual string getName() = 0; // the name of the airline. Should have the last 4 digits of the roll no.
- // return the list of flights for this airline between origin and destination cities
- // The list of flights is appended to the vector flights that is passed in.
- // Input vector flights will not be a null reference
- virtual void findFlights(string origin, string destination,
- vector<Flight *>& flights) {}
- // get the current price for a specified flight of this airline
- virtual float getPrice(Flight *flight) = 0;
- // buy a ticket from this airline for a particular flight
- // Returns true if the ticket can be issues (i.e. there are seats available on the flight
- virtual bool issueTicket(Flight *flight) = 0;
- // number of tickets sold today
- virtual int getNumSold() = 0;
- // get total revenue and passenger km for the day
- virtual void getSalesStats(float& revenue, float& passKm) {}
- };
- class AIR:public Airline{
- protected:
- POR *portal;
- string name;
- int seats,nflightsperday;
- string o,d;
- vector<string> org;
- vector<string> dest;
- vector<int> nflights;
- vector<FLY *> flight_list;
- public:
- //CONSTRUCTOR ??????
- /*
- AIR(){
- ;
- }
- */
- AIR(POR *pl):portal(pl){
- name = "";
- }
- void init(string ifile){
- FLY *ptr;
- ifstream fin;
- fin.open(ifile.c_str(), ios::in);
- fin >> seats;
- while(!fin.eof()){
- fin >> o >> d;
- org.push_back(o);
- dest.push_back(d);
- fin >> nflightsperday;
- nflights.push_back(nflightsperday);
- for(int i=0;i<nflightsperday;i++){
- ptr->setOrigin(o);
- ptr->setDestination(d);
- ptr->setName(ifile.c_str());
- flight_list.push_back(ptr);
- }
- }
- fin.close();
- }
- /*void readfile(ifstream& fin,string ifile){
- fin.open(ifile.c_str(), ios::in);
- fin >> seats;
- while(!fin.eof()){
- fin >> o >> d;
- org.push_back(o);
- dest.push_back(d);
- fin >> nflightsperday;
- nflights.push_back(nflightsperday);
- }
- fin.close();
- }*/
- string getName(){
- //cout<<typeid(obj).name();
- return "AIR";
- }
- void findFlights(string origin, string destination, vector<Flight *>& flights){
- }
- float getPrice(Flight *flight){
- }
- bool issueTicket(Flight *flight){
- }
- int getNumSold(){
- return -1;
- }
- void getTicketStats(float& revenue, float& passKm){
- }
- };
- int main(){
- POR *x=new POR;
- AIR a1(x);
- return 0;
- }
- version4.cpp: In constructor ‘AIR::AIR(POR*)’:
- version4.cpp:303:24: error: no matching function for call to ‘Airline::Airline()’
- AIR(POR *pl):portal(pl){
- ^
- version4.cpp:303:24: note: candidates are:
- version4.cpp:251:2: note: Airline::Airline(Portal*)
- Airline(Portal *pl):portal(pl){
- ^
- version4.cpp:251:2: note: candidate expects 1 argument, 0 provided
- version4.cpp:239:7: note: Airline::Airline(const Airline&)
- class Airline {
- ^
- version4.cpp:239:7: note: candidate expects 1 argument, 0 provided
- AIR::AIR(Portal* p) : Airline(p)
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment