Guest User

Untitled

a guest
Oct 20th, 2016
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.10 KB | None | 0 0
  1. class Portal {
  2. public:
  3. Portal() {}
  4. virtual ~Portal() {}
  5.  
  6. enum SortField {Airline, Time, Duration, Price};
  7. enum SortOrder {Ascending, Descending};
  8. enum BuyOption {Cheapest, Fastest, Earliest, Latest};
  9.  
  10. // initialize route information by reading in input file with government data/guidelines
  11. virtual void initRoutes(string routeInfo) {}
  12.  
  13. // return constraints/guidelines for a given origin+destination combination
  14. virtual void routeInfo(string origin, string destination, float& dist, float& duration, float& minPrice, float& maxPrice, float& timeVariation) {}
  15.  
  16. // display (to cout) the list of flights with available seats between origin and destination
  17. // List is to be shown in sorted order, based on sortField and sortOrder
  18. // sortField is one of the values of enum SortField
  19. // sortOrder is one of values of enum SortOrder
  20. virtual void showFlights(string origin, string destination, SortField sortField = Airline, SortOrder sortOrder = Descending) {}
  21.  
  22. // purchase a ticket based on BuyOption criteria, optionally specifying a preferred airline
  23. // This will be for the last selected origin+destination combination
  24. virtual bool buyTicket(BuyOption cirteria, string airline = NULL) = 0;
  25.  
  26. };
  27.  
  28. class POR: public Portal{
  29. protected:
  30. vector<Route *> rt_list;
  31. public:
  32. void initRoutes(string routeInfo){
  33.  
  34. int n=0;
  35. string line;
  36.  
  37. float val;
  38. string str;
  39.  
  40. ifstream rfile;
  41. rfile.open(routeInfo.c_str(),ios::in);
  42. if(rfile.is_open()){
  43. while(!rfile.eof()){
  44. getline(rfile,line);
  45. ++n;
  46. }
  47. }
  48. rfile.close();
  49.  
  50. rfile.open(routeInfo.c_str(),ios::in);
  51. Route *ptr;
  52.  
  53. while(!rfile.eof()){
  54. rfile >> str;
  55. ptr->setorigin(str);
  56. rfile >> str;
  57. ptr->setdestination(str);
  58. rfile >> val;
  59. ptr->setdistance(val);
  60. rfile >> val;
  61. ptr->setduration(val);
  62. rfile >> val;
  63. ptr->setminpkm(val);
  64. rfile >> val;
  65. ptr->setmaxpkm(val);
  66. rfile >> val;
  67. ptr->setdev(val);
  68.  
  69. rt_list.push_back(ptr);
  70. }
  71. rfile.close();
  72. }
  73.  
  74. void routeInfo(string origin, string destination, float& dist, float& duration,float& minPrice, float& maxPrice, float& timeVariation){
  75. int len = rt_list.size();
  76. string str1,str2;
  77. for(int i = 0;i < len;i++){
  78. str1 = rt_list[i]->getOrigin();
  79. str2 = rt_list[i]->getDestination();
  80. if((str1 == origin and str2 == destination) or (str1 == destination and str2 == origin)){
  81. cout<<rt_list[i]->getDistance();
  82. cout<<rt_list[i]->getDuration();
  83. cout<<rt_list[i]->getMinpkm() * rt_list[i]->getDistance();
  84. cout<<rt_list[i]->getMaxpkm() * rt_list[i]->getDistance();
  85. cout<<rt_list[i]->getDev();
  86. }
  87. }
  88. }
  89.  
  90. void showFlights(string origin, string destination, SortField sortField = Airline,SortOrder sortOrder = Descending){
  91.  
  92. }
  93.  
  94. bool buyTicket(BuyOption cirteria, string airline = NULL){
  95.  
  96. }
  97. };
  98. class Airline {
  99.  
  100. private:
  101. Portal *portal;
  102.  
  103. protected:
  104. Portal *getPortal() {
  105. return portal;
  106. }
  107.  
  108. public:
  109.  
  110. Airline(Portal *pl):portal(pl){
  111.  
  112. }
  113.  
  114. virtual ~Airline() {}
  115.  
  116. // reads in the input file for the airline and initializes its
  117. // information about routes, capacity etc
  118. virtual void init(string ifile) = 0;
  119.  
  120. virtual string getName() = 0; // the name of the airline. Should have the last 4 digits of the roll no.
  121.  
  122. // return the list of flights for this airline between origin and destination cities
  123. // The list of flights is appended to the vector flights that is passed in.
  124. // Input vector flights will not be a null reference
  125. virtual void findFlights(string origin, string destination,
  126. vector<Flight *>& flights) {}
  127.  
  128. // get the current price for a specified flight of this airline
  129. virtual float getPrice(Flight *flight) = 0;
  130.  
  131. // buy a ticket from this airline for a particular flight
  132. // Returns true if the ticket can be issues (i.e. there are seats available on the flight
  133. virtual bool issueTicket(Flight *flight) = 0;
  134.  
  135. // number of tickets sold today
  136. virtual int getNumSold() = 0;
  137.  
  138. // get total revenue and passenger km for the day
  139. virtual void getSalesStats(float& revenue, float& passKm) {}
  140.  
  141. };
  142.  
  143. class AIR:public Airline{
  144. protected:
  145. POR *portal;
  146. string name;
  147. int seats,nflightsperday;
  148. string o,d;
  149. vector<string> org;
  150. vector<string> dest;
  151. vector<int> nflights;
  152. vector<FLY *> flight_list;
  153. public:
  154. //CONSTRUCTOR ??????
  155.  
  156. /*
  157. AIR(){
  158. ;
  159. }
  160. */
  161.  
  162. AIR(POR *pl):portal(pl){
  163. name = "";
  164. }
  165.  
  166. void init(string ifile){
  167. FLY *ptr;
  168. ifstream fin;
  169. fin.open(ifile.c_str(), ios::in);
  170. fin >> seats;
  171. while(!fin.eof()){
  172. fin >> o >> d;
  173. org.push_back(o);
  174. dest.push_back(d);
  175. fin >> nflightsperday;
  176. nflights.push_back(nflightsperday);
  177.  
  178. for(int i=0;i<nflightsperday;i++){
  179. ptr->setOrigin(o);
  180. ptr->setDestination(d);
  181. ptr->setName(ifile.c_str());
  182. flight_list.push_back(ptr);
  183. }
  184.  
  185. }
  186. fin.close();
  187. }
  188.  
  189. /*void readfile(ifstream& fin,string ifile){
  190. fin.open(ifile.c_str(), ios::in);
  191. fin >> seats;
  192. while(!fin.eof()){
  193. fin >> o >> d;
  194. org.push_back(o);
  195. dest.push_back(d);
  196. fin >> nflightsperday;
  197. nflights.push_back(nflightsperday);
  198. }
  199. fin.close();
  200. }*/
  201.  
  202. string getName(){
  203. //cout<<typeid(obj).name();
  204. return "AIR";
  205. }
  206. void findFlights(string origin, string destination, vector<Flight *>& flights){
  207.  
  208. }
  209. float getPrice(Flight *flight){
  210.  
  211. }
  212. bool issueTicket(Flight *flight){
  213.  
  214. }
  215. int getNumSold(){
  216. return -1;
  217. }
  218. void getTicketStats(float& revenue, float& passKm){
  219.  
  220. }
  221. };
  222.  
  223.  
  224. int main(){
  225. POR *x=new POR;
  226. AIR a1(x);
  227. return 0;
  228. }
  229.  
  230. version4.cpp: In constructor ‘AIR::AIR(POR*)’:
  231. version4.cpp:303:24: error: no matching function for call to ‘Airline::Airline()’
  232. AIR(POR *pl):portal(pl){
  233. ^
  234. version4.cpp:303:24: note: candidates are:
  235. version4.cpp:251:2: note: Airline::Airline(Portal*)
  236. Airline(Portal *pl):portal(pl){
  237. ^
  238. version4.cpp:251:2: note: candidate expects 1 argument, 0 provided
  239. version4.cpp:239:7: note: Airline::Airline(const Airline&)
  240. class Airline {
  241. ^
  242. version4.cpp:239:7: note: candidate expects 1 argument, 0 provided
  243.  
  244. AIR::AIR(Portal* p) : Airline(p)
  245. {
  246.  
  247. }
Advertisement
Add Comment
Please, Sign In to add comment