SHARE
TWEET

Untitled

a guest Apr 18th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<string>
  3. #include<cstdlib>
  4. using namespace std;
  5.  
  6. int x = 0, y = 0, z = 0;
  7.  
  8. //Class Definitions for Flight, Passenger, Ticket classes:
  9. class Ticket;
  10. class Passenger;
  11. class Flight
  12. {
  13. protected:
  14.  
  15.   string flight_class;
  16.   //available seats ==> (a-k)(1-21)
  17.  
  18. public:
  19.   int eco_fare;
  20.   int business_fare;
  21.   int first_fare;
  22.   int eco, business, first;
  23.   int ecoav, businessav, firstav;
  24.  
  25.   Flight(){}
  26.   Flight(int eco1, int business1, int first1, float eco_fare1, float business_fare1, float first_fare1)
  27.   {
  28.       eco, ecoav = eco1;
  29.       business, businessav = business1;
  30.       first, firstav = first1;
  31.       eco_fare = eco_fare1;
  32.       business_fare = business_fare1;
  33.       first_fare = first_fare1;
  34.   }
  35.   friend void gen_ticket(Flight &, Ticket *, int *);
  36.   friend void search_pass(Flight &, Flight &, Flight &,  Ticket *, Ticket *, Ticket *);
  37.   friend void edit_pass(Ticket *, Ticket *, Ticket *, Flight &, Flight &, Flight &);
  38.   friend void avail_seats(Flight &, Flight &, Flight &);
  39.   friend void show_ticket(Ticket *, Ticket *, Ticket *, Flight &, Flight &, Flight &);
  40.   friend void cancel_ticket(Ticket *, Ticket *, Ticket *, Flight &, Flight &, Flight &);
  41. };
  42.  
  43. class Passenger
  44. {
  45. protected:
  46.   string name;
  47.   int age;
  48.   char sex;
  49.   string id;
  50.  
  51. public:
  52.   static unsigned int passengerCount;
  53.   Passenger() {};
  54.   Passenger(string nm, int ag, char gn, string p_id)
  55.   {}
  56.   friend void gen_ticket(Flight &, Ticket *, int *);
  57.   friend void search_pass(Flight &, Flight &, Flight &,  Ticket *, Ticket *, Ticket *);
  58.   friend void edit_pass(Ticket *, Ticket *, Ticket *, Flight &, Flight &, Flight &);
  59.   friend void avail_seats(Flight &, Flight &, Flight &);
  60.   friend void show_ticket(Ticket *, Ticket *, Ticket *, Flight &, Flight &, Flight &);
  61.   friend void cancel_ticket(Ticket *, Ticket *, Ticket *, Flight &, Flight &, Flight &);
  62. };
  63.  
  64. class Ticket: protected Passenger, protected Flight
  65. {
  66. private:
  67.   int ticket_id;
  68.   int seat_number;
  69.   int fare;
  70.  
  71. public:
  72.   Ticket() {};
  73.  
  74.   friend void gen_ticket(Flight &, Ticket *, int *);
  75.   friend void show_ticket(Ticket *, Ticket *, Ticket *, Flight &, Flight &, Flight &);
  76.   friend void search_pass(Flight &, Flight &, Flight &, Ticket *, Ticket *, Ticket *);
  77.   friend void edit_pass(Ticket *, Ticket *, Ticket *, Flight &, Flight &, Flight &);
  78.   friend void cancel_ticket(Ticket *, Ticket *, Ticket *, Flight &, Flight &, Flight &);
  79.   void fare_set() //sets fare according to flight_class
  80.   {
  81.     if(flight_class == "economy") {fare = Flight::eco_fare;}
  82.     else if(flight_class == "business") {fare = Flight::business_fare;}
  83.     else if(flight_class == "first") {fare = Flight::first_fare;}
  84.     else {cout << "\nIn_fare_set: invalid flight class!\n";}
  85.   }
  86.     void get_data(string flight_classes);
  87.  
  88. };
  89.  
  90. //initialising static variables
  91. unsigned int Passenger::passengerCount = 0;
  92.  
  93. //Function Definitions:
  94. //gen ticket def
  95. void Ticket::get_data(string flight_classes)
  96. {
  97.     cout<<"\nName: ";
  98.     getline(cin, Passenger::name);
  99.     cout<<"Age: ";
  100.     cin>>Passenger::age;
  101.     cout<<"Gender: ";
  102.     cin>>Passenger::sex;
  103.     cout<<"ID: ";
  104.     getline(cin, Passenger::id);
  105.     Flight::flight_class = flight_classes;
  106. }
  107.  
  108. void gen_ticket(Flight &f1, Ticket *t1, int *x)
  109. {
  110.     if(f1.ecoav<=0 && f1.businessav<=0 && f1.firstav<=0) //eco_av - eco_available
  111.   {
  112.     cout<<"\nSorry! No available seat in this flight\n";
  113.     exit(0);
  114.   }
  115.   if(f1.ecoav<=0)
  116.     cout<<"\nEconomy class is full!\n";
  117.   if(f1.businessav<=0)
  118.     cout<<"\nBusiness class is full!\n";
  119.   if(f1.firstav<=0)
  120.     cout<<"\nFirst class is full!\n";
  121.   cout<<"\nPress 'c' to continue or 'e' to exit\n";
  122.   char ch;
  123.   cin>>ch;
  124.   cin.ignore();
  125.   if(ch=='e')
  126.     exit(0);
  127.   else if(ch=='c')
  128.   {
  129.     string nm;
  130.     int ag, cl_num, tid;
  131.     char gn, answer;
  132.     string f_class, p_id;
  133.  
  134.     cout<<"\nName: ";
  135.     std::getline(std::cin, nm);
  136.     cout<<"Age: ";
  137.     cin>>ag;
  138.     cout<<"Gender: ";
  139.     cin>>gn;
  140.     cout<<"Passenger ID: ";
  141.     cin>>p_id;
  142.  
  143.     Passenger::passengerCount += 1;
  144.     tid = 1000 + Passenger::passengerCount;        
  145.  
  146.     do
  147.     {
  148.         cout<<"\n[+] 1 for economy class\n[+] 2 for business class\n[+] 3 for first class\nPlease enter the class: ";
  149.       cin>>cl_num;
  150.  
  151.       if(cl_num==1 && f1.ecoav>0)
  152.       {
  153.         f_class="economy";
  154.         Ticket t;
  155.                 t.get_data("economy");
  156.         t1[*x] = t;
  157.         *x++;
  158.         break;
  159.       }
  160.       else if(cl_num==2 && f1.businessav>0)
  161.       {
  162.         f_class="business";
  163.         Ticket t;
  164.                 t.get_data("business");
  165.         t1[*x] = t;
  166.         *x++;
  167.         break;
  168.       }
  169.       else if(cl_num==3 && f1.firstav>0)
  170.       {
  171.         f_class="first";
  172.         Ticket t;
  173.                 t.get_data("first");
  174.         t1[*x]= t;
  175.         *x++;
  176.         break;
  177.       }
  178.       else
  179.       {
  180.         cout<<"\n\nWrong input !!\n";
  181.         cout<<"\n\nDo you want to try again ? (y/n)\n";
  182.         cin>>answer;
  183.         cin.ignore();
  184.       }
  185.         }
  186.         while(answer=='y' || answer=='Y');
  187.     }
  188. }
  189.  
  190. void search_pass(Flight &f1, Flight &f2, Flight &f3,  Ticket *t1, Ticket *t2, Ticket *t3) //Search Passenger Details
  191. {
  192.     char ans;
  193.     do
  194.     {
  195.         int num;
  196.         cout<<"\n[1] Search by Flight\
  197.                  \n[2] Search by Class\
  198.                  \n\nEnter your choice: ";
  199.     cin >> num;
  200.     if(num == 1)
  201.     {
  202.         int flight_num, i;
  203.         char cont;
  204.         do
  205.         {
  206.             cout << "\n\n[+] 1 for Flight 1\n[+] 2 for Flight 2\n[+] 3 for Flight 3\nPlease enter the flight number: ";
  207.         cin>>flight_num;
  208.         if(flight_num==1)
  209.         {
  210.             for(i=0;i<(f1.eco+f1.business+f1.first);i++)
  211.             {
  212.                 cout<<"\n\nName: "<<t1[i].name<<"\nAge: "<<t1[i].age<<"\nGender: "<<t1[i].sex<<"\nPassenger ID: "<<t1[i].id;
  213.                 cout<<"\nClass: "<<t1[i].flight_class<<"\nTicket number: "<<t1[i].ticket_id<<"\nSeat Number: "<<t1[i].seat_number;
  214.             }
  215.         }
  216.         else if(flight_num==2)
  217.         {
  218.             for(i=0;i<(f2.eco+f2.business+f2.first);i++)
  219.             {
  220.                 cout<<"\n\nName: "<<t2[i].name<<"\nAge: "<<t2[i].age<<"\nGender: "<<t2[i].sex<<"\nPassenger ID: "<<t2[i].id;
  221.                 cout<<"\nClass: "<<t2[i].flight_class<<"\nTicket number: "<<t2[i].ticket_id<<"\nSeat Number: "<<t2[i].seat_number;
  222.             }          
  223.         }
  224.         else if(flight_num==3)
  225.         {
  226.             for(i=0;i<(f3.eco+f3.business+f3.first);i++)
  227.             {
  228.                 cout<<"\n\nName: "<<t3[i].name<<"\nAge: "<<t3[i].age<<"\nGender: "<<t3[i].sex<<"\nPassenger ID: "<<t3[i].id;
  229.                 cout<<"\nClass: "<<t3[i].flight_class<<"\nTicket number: "<<t3[i].ticket_id<<"\nSeat Number: "<<t3[i].seat_number;
  230.             }          
  231.         }
  232.         else
  233.         {
  234.                 cout<<"\n\nPlease enter correct option\n\n";
  235.                 cout<<"Do you want to continue ? (y/n)\n";
  236.                 cin>>cont;
  237.                 cin.ignore();
  238.         }
  239.         }
  240.         while(cont=='y' || cont=='Y');
  241.         }
  242.  
  243.     else if(num==2)
  244.     {
  245.         char class_loop;
  246.         do
  247.         {
  248.             int class_choice, i;
  249.             cout<<"\n\n[1] Economy\n[2] Business\n[3] First\n\nEnter your choice: ";
  250.             cin>>class_choice;
  251.             if(class_choice==1)
  252.             {
  253.                 for(i=0;i<(f1.eco+f1.business+f1.first);i++)
  254.                 {
  255.                     if(t1[i].flight_class=="economy")
  256.                     {
  257.                     cout<<"\n\nName: "<<t1[i].name<<"\nAge: "<<t1[i].age<<"\nGender: "<<t1[i].sex<<"\nPassenger ID: "<<t1[i].id;
  258.                     cout<<"\nClass: "<<t1[i].flight_class<<"\nTicket number: "<<t1[i].ticket_id<<"\nSeat Number: "<<t1[i].seat_number;
  259.                     }
  260.                     if(t2[i].flight_class=="economy")
  261.                     {
  262.                     cout<<"\n\nName: "<<t2[i].name<<"\nAge: "<<t2[i].age<<"\nGender: "<<t2[i].sex<<"\nPassenger ID: "<<t2[i].id;
  263.                     cout<<"\nClass: "<<t2[i].flight_class<<"\nTicket number: "<<t2[i].ticket_id<<"\nSeat Number: "<<t2[i].seat_number;
  264.                     }  
  265.                     if(t3[i].flight_class=="economy")  
  266.                     {
  267.                         cout<<"\n\nName: "<<t3[i].name<<"\nAge: "<<t3[i].age<<"\nGender: "<<t3[i].sex<<"\nPassenger ID: "<<t3[i].id;
  268.                     cout<<"\nClass: "<<t3[i].flight_class<<"\nTicket number: "<<t3[i].ticket_id<<"\nSeat Number: "<<t3[i].seat_number;
  269.                     }      
  270.                 }
  271.             }
  272.             else if(class_choice==2)
  273.             {
  274.                 for(i=0;i<(f1.eco+f1.business+f1.first);i++)
  275.                 {
  276.                     if(t1[i].flight_class=="business")
  277.                     {
  278.                     cout<<"\n\nName: "<<t1[i].name<<"\nAge: "<<t1[i].age<<"\nGender: "<<t1[i].sex<<"\nPassenger ID: "<<t1[i].id;
  279.                     cout<<"\nClass: "<<t1[i].flight_class<<"\nTicket number: "<<t1[i].ticket_id<<"\nSeat Number: "<<t1[i].seat_number;
  280.                     }
  281.                     if(t2[i].flight_class=="business")
  282.                     {
  283.                     cout<<"\n\nName: "<<t2[i].name<<"\nAge: "<<t2[i].age<<"\nGender: "<<t2[i].sex<<"\nPassenger ID: "<<t2[i].id;
  284.                     cout<<"\nClass: "<<t2[i].flight_class<<"\nTicket number: "<<t2[i].ticket_id<<"\nSeat Number: "<<t2[i].seat_number;
  285.                     }  
  286.                     if(t3[i].flight_class=="business")  
  287.                     {
  288.                         cout<<"\n\nName: "<<t3[i].name<<"\nAge: "<<t3[i].age<<"\nGender: "<<t3[i].sex<<"\nPassenger ID: "<<t3[i].id;
  289.                     cout<<"\nClass: "<<t3[i].flight_class<<"\nTicket number: "<<t3[i].ticket_id<<"\nSeat Number: "<<t3[i].seat_number;
  290.                     }      
  291.                 }
  292.             }
  293.             else if(class_choice==3)
  294.             {
  295.                 for(i=0;i<(f1.eco+f1.business+f1.first);i++)
  296.                 {
  297.                     if(t1[i].flight_class=="first")
  298.                     {
  299.                     cout<<"\n\nName: "<<t1[i].name<<"\nAge: "<<t1[i].age<<"\nGender: "<<t1[i].sex<<"\nPassenger ID: "<<t1[i].id;
  300.                     cout<<"\nClass: "<<t1[i].flight_class<<"\nTicket number: "<<t1[i].ticket_id<<"\nSeat Number: "<<t1[i].seat_number;
  301.                     }
  302.                     if(t2[i].flight_class=="first")
  303.                     {
  304.                     cout<<"\n\nName: "<<t2[i].name<<"\nAge: "<<t2[i].age<<"\nGender: "<<t2[i].sex<<"\nPassenger ID: "<<t2[i].id;
  305.                     cout<<"\nClass: "<<t2[i].flight_class<<"\nTicket number: "<<t2[i].ticket_id<<"\nSeat Number: "<<t2[i].seat_number;
  306.                     }  
  307.                     if(t3[i].flight_class=="first")  
  308.                     {
  309.                         cout<<"\n\nName: "<<t3[i].name<<"\nAge: "<<t3[i].age<<"\nGender: "<<t3[i].sex<<"\nPassenger ID: "<<t3[i].id;
  310.                     cout<<"\nClass: "<<t3[i].flight_class<<"\nTicket number: "<<t3[i].ticket_id<<"\nSeat Number: "<<t3[i].seat_number;
  311.                     }      
  312.                 }  
  313.             }
  314.  
  315.             else
  316.             {
  317.                 cout<<"\n\nPlease enter correct option\n\n";
  318.                 cout<<"Do you want to continue ? (y/n)\n";
  319.                 cin>>class_loop;
  320.                 cin.ignore();          
  321.             }
  322.         }
  323.         while(class_loop=='y' || class_loop=='Y'); 
  324.     }
  325.     else
  326.     {
  327.         cout<<"\n\nPlease enter correct option\n\n";
  328.         cout<<"Do you want to continue ? (y/n)\n";
  329.         cin>>ans;
  330.         cin.ignore();
  331.     }
  332.     }
  333.     while(ans=='y' || ans=='Y');
  334. }
  335.  
  336. void edit_pass(Ticket *t1, Ticket *t2, Ticket *t3, Flight &f1, Flight &f2, Flight &f3) //pass only flight 3 (flight 3 has max seating capacity for all 3 classes{our signature Boeing})
  337. {
  338.     char more;
  339.     do
  340.     {
  341.         int i, tic_id, found=0;
  342.         string i_d, pass_name;
  343.         char gen;
  344.         int pass_age;
  345.         cout<<"\n\nPassenger ID: ";
  346.         cin>>i_d;
  347.         cout<<"\nTicket number: ";
  348.         cin>>tic_id;
  349.         for(i=0;i<(f1.eco+f1.business+f1.first);i++)
  350.         {
  351.             if(t1[i].ticket_id==tic_id || t1[i].id==i_d)
  352.             {
  353.                 cout<<"\n\nName: ";
  354.                 cin>>pass_name;
  355.                 t1[i].name = pass_name;
  356.                 cout<<"Gender: ";
  357.                 cin>>gen;
  358.                 t1[i].sex = gen;
  359.                 cout<<"Age: ";
  360.                 cin>>pass_age;
  361.                 t1[i].age = pass_age;
  362.  
  363.                 found = 1;
  364.                 break;
  365.             }
  366.         }
  367.  
  368.         for(i=0;i<(f2.eco+f2.business+f2.first);i++)
  369.         {
  370.             if(found==1)
  371.                 break;
  372.             if(t2[i].ticket_id==tic_id || t2[i].id==i_d)
  373.             {
  374.                 cout<<"\n\nName: ";
  375.                 cin>>pass_name;
  376.                 t2[i].name = pass_name;
  377.                 cout<<"Gender: ";
  378.                 cin>>gen;
  379.                 t2[i].sex = gen;
  380.                 cout<<"Age: ";
  381.                 cin>>pass_age;
  382.                 t2[i].age = pass_age;
  383.  
  384.                 found = 1;
  385.                 break;
  386.             }
  387.         }
  388.  
  389.         for(i=0;i<(f2.eco+f2.business+f2.first);i++)
  390.         {
  391.             if(found==1)
  392.                 break;
  393.             if(t3[i].ticket_id==tic_id || t3[i].id==i_d)
  394.             {
  395.                 cout<<"\n\nName: ";
  396.                 cin>>pass_name;
  397.                 t3[i].name = pass_name;
  398.                 cout<<"Gender: ";
  399.                 cin>>gen;
  400.                 t3[i].sex = gen;
  401.                 cout<<"Age: ";
  402.                 cin>>pass_age;
  403.                 t3[i].age = pass_age;
  404.  
  405.                 found = 1;
  406.                 break;
  407.             }
  408.         }
  409.  
  410.         if(found==0)
  411.             {cout<<"\n\nNo passenger found !\n\n";}
  412.         cout<<"\n\nDo you want to edit details of another passenger ? (y/n)\n";
  413.         cin>>more;
  414.         cin.ignore();  
  415.     }
  416.     while(more=='y' || more=='Y');
  417. }
  418.  
  419. void avail_seats(Flight &f1, Flight &f2, Flight &f3) //available seats
  420. {
  421.     char do_while;
  422.     do
  423.     {
  424.         int fn1;
  425.         cout << "\n\n[1] Flight 1\n[2] Flight 2\n[3] Flight 3\n\nEnter your flight: ";
  426.         cin >> fn1;
  427.         if(fn1 == 1)
  428.             cout << "\n\nEconomy: " << f1.ecoav << "\nBusiness: " << f1.businessav << "\nFirst: " << f1.firstav;
  429.         else if(fn1 == 2)
  430.             cout << "\n\nEconomy: " << f2.ecoav << "\nBusiness: " << f2.businessav << "\nFirst: " << f2.firstav;
  431.         else if(fn1 == 3)
  432.             cout << "\n\nEconomy: " << f3.ecoav << "\nBusiness: " << f3.businessav << "\nFirst: " << f3.firstav;
  433.         else
  434.             cout << "\n\nPlease enter correct option !!\n\n";
  435.         cout << "Do you want to check seat availibility of other flights ? (y/n)\n";
  436.         cin >> do_while;
  437.     }
  438.     while(do_while == 'y' || do_while == 'Y');
  439. }
  440.  
  441. void show_ticket(Ticket *t1, Ticket *t2, Ticket *t3, Flight &f1, Flight &f2, Flight &f3)
  442. {
  443.     string p_id1;
  444.     char try_again;
  445.     do
  446.     {
  447.         int i, j, found=0;
  448.  
  449.         cout<<"\nPassenger ID: ";
  450.         cin>>p_id1;
  451.        
  452.         for(i=0;i<(f1.eco+f1.business+f1.first);i++)
  453.         {
  454.             if(t1[i].id == p_id1)
  455.             {
  456.                 for(j=i;j<(f1.eco+f1.business+f1.first);j++)
  457.                 {
  458.                     cout<<"\n\nName: "<<t1[i].name<<"\nAge: "<<t1[i].age<<"\nGender: "<<t1[i].sex<<"\nPassenger ID: "<<t1[i].id;
  459.             cout<<"\nClass: "<<t1[i].flight_class<<"\nTicket number: "<<t1[i].ticket_id<<"\nSeat Number: "<<t1[i].seat_number;
  460.                 }
  461.                 found = 1;
  462.                 break;
  463.             }
  464.         }
  465.  
  466.         for(i=0;i<(f2.eco+f2.business+f2.first);i++)
  467.         {
  468.             if(found==1)
  469.                 break;
  470.             if(t2[i].id == p_id1)
  471.             {
  472.                 for(j=i;j<(f1.eco+f1.business+f1.first);j++)
  473.                 {
  474.                     cout<<"\n\nName: "<<t2[i].name<<"\nAge: "<<t2[i].age<<"\nGender: "<<t2[i].sex<<"\nPassenger ID: "<<t2[i].id;
  475.             cout<<"\nClass: "<<t2[i].flight_class<<"\nTicket number: "<<t2[i].ticket_id<<"\nSeat Number: "<<t2[i].seat_number;
  476.                 }
  477.                 found = 1;
  478.                 break;
  479.             }
  480.         }
  481.  
  482.         for(i=0;i<(f3.eco+f3.business+f3.first);i++)
  483.         {
  484.             if(t3[i].id == p_id1)
  485.             {
  486.                 if(found==1)
  487.                     break;
  488.                 for(j=i;j<(f1.eco+f1.business+f1.first);j++)
  489.                 {
  490.                     cout<<"\n\nName: "<<t3[i].name<<"\nAge: "<<t3[i].age<<"\nGender: "<<t3[i].sex<<"\nPassenger ID: "<<t3[i].id;
  491.             cout<<"\nClass: "<<t3[i].flight_class<<"\nTicket number: "<<t3[i].ticket_id<<"\nSeat Number: "<<t3[i].seat_number;
  492.                 }
  493.                 found = 1;
  494.                 break;
  495.             }
  496.         }
  497.  
  498.         if(found==0)
  499.         {
  500.             cout<<"\n\nNo passenger found\n\n";
  501.             cout<<"Do you want to continue ? (y/n)\n";
  502.             cin>>try_again;
  503.             cin.ignore();
  504.         }
  505.  
  506.     }
  507.     while(try_again=='y' || try_again=='Y');
  508. }
  509.  
  510. void cancel_ticket(Ticket *t1, Ticket *t2, Ticket *t3, Flight &f1, Flight &f2, Flight &f3)
  511. {
  512.     string p_id1;
  513.     char try_again;
  514.     do
  515.     {
  516.         int i, j, found=0;
  517.  
  518.         cout<<"\nPassenger ID: ";
  519.         cin>>p_id1;
  520.        
  521.         for(i=0;i<(f1.eco+f1.business+f1.first);i++)
  522.         {
  523.             if(t1[i].id == p_id1)
  524.             {
  525.                 for(j=i;j<(f1.eco+f1.business+f1.first);j++)
  526.                 {
  527.                     t1[j]=t1[j+1];
  528.                 }
  529.                 found = 1;
  530.                 break;
  531.             }
  532.         }
  533.  
  534.         for(i=0;i<(f2.eco+f2.business+f2.first);i++)
  535.         {
  536.             if(found==1)
  537.                 break;
  538.             if(t2[i].id == p_id1)
  539.             {
  540.                 for(j=i;j<(f1.eco+f1.business+f1.first);j++)
  541.                 {
  542.                     t2[j]=t2[j+1];
  543.                 }
  544.                 found = 1;
  545.                 break;
  546.             }
  547.         }
  548.  
  549.         for(i=0;i<(f3.eco+f3.business+f3.first);i++)
  550.         {
  551.             if(t3[i].id == p_id1)
  552.             {
  553.                 if(found==1)
  554.                     break;
  555.                 for(j=i;j<(f1.eco+f1.business+f1.first);j++)
  556.                 {
  557.                     t3[j]=t3[j+1];
  558.                 }
  559.                 found = 1;
  560.                 break;
  561.             }
  562.         }
  563.  
  564.         if(found==0)
  565.         {
  566.             cout<<"\n\nNo passenger found\n\n";
  567.             cout<<"Do you want to continue ? (y/n)\n";
  568.             cin>>try_again;
  569.             cin.ignore();
  570.         }
  571.  
  572.     }
  573.     while(try_again=='y' || try_again=='Y');
  574. }
  575.  
  576.  
  577. //Main Program
  578. int main()
  579. {
  580.   int op_num, adm, fn, flight_num; //variable declaration
  581.   char ans;
  582.  
  583.   Flight f1(2, 3, 4, 100.0F, 200.0F, 300.0F); //initialising flight objects
  584.   Flight f2(3, 4, 5, 100.0F, 200.0F, 300.0F);
  585.   Flight f3(4, 5, 6, 100.0F, 200.0F, 300.0F);
  586.   Ticket t1[9], t2[12], t3[15]; //initiating ticket arrays
  587.  
  588.   string loginId, loginPass, lDivider;
  589.   lDivider = "\n\n===========================================================\n\n";
  590.   cout<<"\t\tWelcome to the \"Bazooka Airline\"\n\n";
  591.  
  592.   //Main Menu
  593.   do
  594.   {
  595.     cout << "Main Menu:\n";
  596.     cout << "\n[1] Administrator Login\
  597.              \n[2] Passenger Menu\
  598.              \nPlease enter one of above option number: ";
  599.     cin >> op_num;
  600.  
  601.     if(op_num == 1) //Administrator Login page:
  602.     {
  603.       cout << lDivider;
  604.  
  605.       cout << "Login ID: ";
  606.       cin >> loginId;
  607.       cout << "Password: ";
  608.       cin >> loginPass;
  609.       if(loginId == "admin1" && loginPass == "witchsavannah")
  610.       {
  611.         cout << "\n[1] Search passenger details\
  612.                      \n[2] Edit passenger details\
  613.                  \n[3] Check available seats\
  614.                  \n[4] Exit\
  615.                  \nPlease enter the option number: ";
  616.         cin >> adm;
  617.  
  618.         //Admin menu
  619.         if(adm == 1) //search_passengers : by flight and by class
  620.         {
  621.           search_pass(f1, f2, f3, t1, t2, t3);
  622.         }
  623.  
  624.         else if(adm == 2) //edit_passenger_details ----- TO BE EDITED!!!!
  625.         {
  626.           edit_pass(t1, t2, t3, f1, f2, f3);
  627.         }
  628.  
  629.         else if(adm == 3) //check_seat_availability
  630.         {
  631.           avail_seats(f1, f2, f3);
  632.         }
  633.        
  634.         else //exit
  635.         {
  636.           exit(0);
  637.         }
  638.  
  639.         cout << "\n\nDo you wish to continue ? (Y/N)\n";
  640.         cin >> ans;
  641.         cout << "\n";
  642.         cout<<"\n\nDo you wish to continue ? (Y/N)\n";
  643.         cin>>ans;
  644.         cout<<"\n";
  645.         }
  646.         }
  647.     else if(op_num==2) //Passenger menu
  648.     {
  649.         cout << lDivider;
  650.         //Display Options
  651.         cout << "\n[1] New Reservation\
  652.                \n[2] Ticket Display\
  653.                  \n[3] Ticket Cancellation\
  654.                \n[4] Exit\
  655.                  \nPlease enter one of above option number: ";
  656.         cin >> fn;
  657.         if(fn==1) //New Reservation
  658.         {
  659.                 cout << "Enter (1) for flight 1, (2) for flight 2 and (3) for flight 3";
  660.         cin>>flight_num;
  661.                 if(flight_num==1)
  662.             gen_ticket(f1, t1, &x);
  663.                 else if(flight_num==2)
  664.                     gen_ticket(f2, t2, &y);
  665.                 else if(flight_num==3)
  666.                     gen_ticket(f3, t3, &z);
  667.         }
  668.       else if(fn==2) //Ticket Display
  669.       {
  670.         show_ticket(t1, t2, t3, f1, f2, f3);
  671.       }
  672.       else if(fn==3) //Ticket Cancellation
  673.       {
  674.         cancel_ticket(t1, t2, t3, f1, f2, f3);
  675.       }
  676.       else //Exit
  677.       {
  678.         cout << "Exiting...";
  679.         break;
  680.       }
  681.  
  682.       cout << "\n\nDo you wish to continue? (Y/N)\n" ;
  683.       cin >> ans;
  684.       cout << lDivider;
  685.     }
  686.   }
  687.   while(ans == 'y' || ans == 'Y');
  688.  
  689.   if(ans == 'n' || ans == 'N') //If program is aborted
  690.     cout << "\nThank you for traveling with \"Bazooka Airline\"\n\n";
  691.  
  692.   return 0;
  693. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top