Guest User

Untitled

a guest
Oct 22nd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 25.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <ctime>
  4. #include <cstdlib>
  5. using namespace std;
  6.  
  7. #include <stdlib.h>
  8.  
  9. struct nodeMorning{
  10. //  string name;
  11.     char name[50];
  12. //  string address;
  13.     char address[50];
  14.     int phone;
  15.     int sitNum;
  16.     int seat[5][4];
  17.     nodeMorning *nxt;
  18. };
  19.  
  20. char seatCheck[5][4];
  21.  
  22. struct nodeAfternoon{
  23.     //string name;
  24.     char name[50];
  25. //  string address;
  26.     char address[50];
  27.     int phone;
  28.     int sitNum;
  29.     int seat[8][4];
  30.     nodeAfternoon *nxt;
  31. };
  32.  
  33. char seatCheCheck2 [8][4];
  34.  
  35. void transfer(char[][4], nodeMorning[][4]);
  36.  
  37. void bookFlightMenu(); //check
  38. void cancelFlightMenu(); //check
  39. void displayFlightMenu(); //check
  40. void transferFlightMenu(); //check
  41. void changeSeatMenu(); //check
  42. void cancelMornFlight();
  43.  
  44. void addAMflight(); //check
  45. void addPMflight(); //check
  46.  
  47. void cancelAMflight(); //check
  48. void cancelPMflight(); //check
  49.  
  50. void displayAMflight(); //check
  51. void displayPMflight(); //check
  52.  
  53. void transferAMflight();
  54. void transferPMflight();
  55.  
  56. void changeAMflight(); //check
  57. void changePMflight(); //done, still haven't check
  58.  
  59. nodeMorning *startAM = NULL;
  60. nodeAfternoon *startPM = NULL;
  61.  
  62. //--------------------------------------MAIN------------------------------------------
  63. void main(){
  64.     int choice = 0;
  65.  
  66.     do{
  67.     system("CLS");
  68.  
  69.     cout << "MENU: " << endl;
  70.     cout << "[1] Book Flight" << endl;
  71.     cout << "[2] Cancel Flight" << endl;
  72.     cout << "[3] Display Passenger List" << endl;
  73.     cout << "[4] Transfer Flights" << endl;
  74.     cout << "[5] Change Seat Assignment" << endl;
  75.     cout << "[6] Morning Flight Cancelled" << endl;
  76.     cout << "[7] Exit" << endl;
  77.  
  78.     cout << "What do you want to do? : " << endl;
  79.     cin >> choice;
  80.     cin.ignore();
  81.  
  82.     switch(choice){
  83.     case 1: bookFlightMenu();
  84.             break;
  85.     case 2: cancelFlightMenu();
  86.             break;
  87.     case 3: displayFlightMenu();
  88.             break;
  89.     case 4: transferFlightMenu();
  90.             break;
  91.     case 5: changeSeatMenu();
  92.             break;
  93.     case 6: cancelMornFlight();
  94.             break;
  95.     case 7: cout << "Thank you!" << endl;
  96.             break;
  97.  
  98.     }
  99.  
  100.     }while(choice!=7);
  101. }
  102.  
  103. //----------------------------------------CLOSE MAIN--------------------------------------------------
  104.  
  105.  
  106. //-----------------------------------------BOOK FLIGHT MENU-------------------------------------
  107. void bookFlightMenu(){
  108.     int choice = 0;
  109.  
  110.     do{
  111.     system("CLS");
  112.  
  113.     cout << "BOOKFLIGHT MENU: " << endl;
  114.     cout << "[1] Morning Flight" << endl;
  115.     cout << "[2] Afternoon Flight" << endl;
  116.     cout << "[3] Go back to Main Menu" << endl;
  117.  
  118.     cout << "Which do you prefer? : " << endl;
  119.     cin >> choice;
  120.     cin.ignore();
  121.  
  122.     switch(choice){
  123.     case 1: addAMflight();
  124.             system("PAUSE");
  125.             break;
  126.     case 2: addPMflight();
  127.             system("PAUSE");
  128.             break;
  129.     case 3: cout << "Thank you!" << endl;
  130.             system("PAUSE");
  131.             break;
  132.  
  133.     }
  134.  
  135.     }while(choice!=3);
  136. }
  137.  
  138. //-----------------------------------CANCEL FLIGHT MENU------------------------------------------
  139. void cancelFlightMenu(){ //delete
  140.     int choice = 0;
  141.  
  142.     do{
  143.     system("CLS");
  144.  
  145.     cout << "CANCEL FLIGHT MENU: " << endl;
  146.     cout << "[1] Morning Flight" << endl;
  147.     cout << "[2] Afternoon Flight" << endl;
  148.     cout << "[3] Go back to Main Menu" << endl;
  149.  
  150.     cout << "Cancel Flight? : " << endl;
  151.     cin >> choice;
  152.     cin.ignore();
  153.  
  154.     switch(choice){
  155.     case 1: cancelAMflight();
  156.             system("PAUSE");
  157.             break;
  158.     case 2: cancelPMflight();
  159.             system("PAUSE");
  160.             break;
  161.     case 3: cout << "Thank you!" << endl;
  162.             break;
  163.  
  164.     }
  165.  
  166.     }while(choice!=3);
  167.  
  168. }
  169.  
  170. //-----------------------------DISPLAY FLIGHT MENU-----------------------------------------
  171. void displayFlightMenu(){
  172.     int choice = 0;
  173.  
  174.     do{
  175.     system("CLS");
  176.  
  177.     cout << "Display FLIGHT MENU: " << endl;
  178.     cout << "[1] Morning Flight" << endl;
  179.     cout << "[2] Afternoon Flight" << endl;
  180.     cout << "[3] Go back to Main Menu" << endl;
  181.  
  182.     cout << "Display Flight? : " << endl;
  183.     cin >> choice;
  184.     cin.ignore();
  185.  
  186.     switch(choice){
  187.     case 1: displayAMflight();
  188.             break;
  189.     case 2: displayPMflight();
  190.             break;
  191.     case 3: cout << "Thank you!" << endl;
  192.             break;
  193.  
  194.     }
  195.  
  196.     }while(choice!=3);
  197.  
  198. }
  199.  
  200. //-------------------------CANCEL MORNING FLIGHT ----------------------------------
  201. void cancelMornFlight(){
  202. }
  203.  
  204. void transferFlightMenu(){
  205.     int choice = 0;
  206.  
  207.     do{
  208.     system("CLS");
  209.  
  210.     cout << "TRANSFER FLIGHT MENU: " << endl;
  211.     cout << "[1] From Morning Flight to Afternoon Flight" << endl;
  212.     cout << "[2] From Afternoon Flight to Morning Flight" << endl;
  213.     cout << "[3] Go back to Main Menu" << endl;
  214.  
  215.     cout << "Transfer Flight? : " << endl;
  216.     cin >> choice;
  217.     cin.ignore();
  218.  
  219.     switch(choice){
  220.     case 1: transferAMflight();
  221.             system("pause");
  222.             break;
  223. //  case 2: transferPMflight();
  224.             break;
  225. //  case 3: cout << "Thank you!" << endl;
  226.             break;
  227.  
  228.     }
  229.  
  230.     }while(choice!=3);
  231. }
  232.  
  233. void changeSeatMenu(){
  234.     int choice = 0;
  235.  
  236.     do{
  237.     system("CLS");
  238.  
  239.     cout << "CHANGE SEAT MENU: " << endl;
  240.     cout << "[1] From Morning Flight" << endl;
  241.     cout << "[2] From Afternoon Flight" << endl;
  242.     cout << "[3] Go back to Main Menu" << endl;
  243.  
  244.     cout << "Change Seats? : " << endl;
  245.     cin >> choice;
  246.     cin.ignore();
  247.  
  248.     switch(choice){
  249.     case 1: changeAMflight();
  250.             system("pause");
  251.             break;
  252. //  case 2: changePMflight();
  253.             break;
  254. //  case 3: cout << "Thank you!" << endl;
  255.             break;
  256.  
  257.     }
  258.  
  259.     }while(choice!=3);
  260. }
  261.  
  262. //-------------------------ADD MORNING FLIGHT-----------------------------------------
  263. void addAMflight(){
  264.     nodeMorning *addnode;
  265.     nodeMorning *temp = startAM;
  266.     int ans=2;
  267.  
  268.     if(startAM == NULL){
  269.         addnode = new nodeMorning;
  270.        
  271.  
  272.         cout << "Enter your name: " << endl;
  273.     //  getline(cin, addnode->name);
  274.         cin.getline(addnode->name, 50);
  275.         cout << "Enter your phone number: " << endl;
  276.         cin >> addnode->phone;
  277.         cin.ignore();
  278.         cout << "Enter your address: " << endl;
  279.     //  getline(cin, addnode->address);
  280.         cin.getline(addnode->address, 50);
  281.        
  282.  
  283.         cout << "Would you like to choose your own seat? 1 for yes/ 0 for no" << endl;
  284.         cin >> ans;
  285.         cin.ignore();
  286.  
  287.         //-----DISPLAY AND INITIALIZING SEAT------
  288.         cout<<"This is the seating arrangement. Left and Right sides are window seats.";
  289.         int num=20;
  290.         for(int r=0; r<5; r++){
  291.             cout<<endl;
  292.             for(int c=0; c<4; c++){
  293.                 addnode->seat[r][c]=num;
  294.                 cout<<" "<<addnode->seat[r][c];
  295.                 cout<<"\t";
  296.                 num--;
  297.             }
  298.         }
  299.  
  300.         for(int q=0; q<5; q++){
  301.             cout<<endl;
  302.             for(int w=0; w<4; w++){
  303.                 seatCheck[q][w]='o';
  304.                 cout<<" "<<seatCheck[q][w];
  305.                 cout<<"\t";
  306.             }
  307.         }
  308.  
  309.         if(ans==1){
  310.             cout<<endl;
  311.             cout<<"Where would you like to seat?"<<endl;
  312.             cin>> addnode->sitNum;
  313.  
  314.             //---SEARCHING ROWS AND COLUMNS--------------
  315.  
  316.             for(int rs=0; rs<5; rs++){
  317.                 for(int cs=0; cs<4; cs++){
  318.                     if(addnode->seat[rs][cs] == addnode->sitNum){
  319.                         cout<<"Your seat number is "<<addnode->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
  320.                         seatCheck[rs][cs] = 'x';
  321.                     }
  322.                 }
  323.             }
  324.  
  325.             system("pause");
  326.         }
  327.  
  328.         else{
  329.             cout<<endl;
  330.             cout<<"Your seat will be chosen randomly. . ."<<endl;
  331.             srand(time(0));
  332.             addnode->sitNum = (rand() % 20) + 1;
  333.            
  334.             //---SEARCHING ROWS AND COLUMNS--------------
  335.  
  336.             for(int rs=0; rs<5; rs++){
  337.                 for(int cs=0; cs<4; cs++){
  338.                     if(addnode->seat[rs][cs] == addnode->sitNum){
  339.                         cout<<"Your seat number is "<<addnode->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
  340.                         seatCheck[rs][cs] = 'x';
  341.                     }
  342.                 }
  343.             }
  344.  
  345.         }
  346.  
  347.         addnode->nxt=NULL;
  348.         startAM=addnode;
  349.     }
  350.  
  351.     else{
  352.         addnode = new nodeMorning;
  353.         int taken;
  354.  
  355.         taken=0;
  356.  
  357.         for(int d=0; d<5; d++){
  358.             cout<<endl;
  359.             for(int t=0; t<4; t++){
  360.                 cout<<" "<<seatCheck[d][t];
  361.                 cout<<"\t";
  362.             }
  363.         }
  364.  
  365.         cout << "Enter your name: " << endl;
  366.         //getline(cin, addnode->name);
  367.         cin.getline(addnode->name, 50);
  368.         cout << "Enter your phone number: " << endl;
  369.         cin >> addnode->phone;
  370.         cin.ignore();
  371.         cout << "Enter your address: " << endl;
  372.         //getline(cin, addnode->address);
  373.         cin.getline(addnode->address, 50);
  374.        
  375.  
  376.         cout << "Would you like to choose your own seat? 1 for yes/ 0 for no" << endl;
  377.         cin >> ans;
  378.         cin.ignore();
  379.  
  380.         //-----DISPLAY AND INITIALIZING SEAT------
  381.         cout<<"This is the seating arrangement. Left and Right sides are window seats.";
  382.         int num=20;
  383.         for(int r=0; r<5; r++){
  384.             cout<<endl;
  385.             for(int c=0; c<4; c++){
  386.                 addnode->seat[r][c]=num;
  387.                 cout<<" "<<addnode->seat[r][c];
  388.                 cout<<"\t";
  389.                 num--;
  390.             }
  391.         }
  392.        
  393.         if(ans==1){
  394.            
  395.             do{
  396.                 if(taken==0)
  397.                     cout<<"Where would you like to seat?"<<endl;
  398.                 else
  399.                     cout<<"The seat is already taken. Choose another seat."<<endl;
  400.                 cin>>addnode->sitNum;
  401.  
  402.                
  403.                 //---SEARCHING ROWS AND COLUMNS--------------
  404.  
  405.  
  406.                 for(int rs=0; rs<5; rs++){
  407.                     for(int cs=0; cs<4; cs++){
  408.                         if(addnode->seat[rs][cs] == addnode->sitNum){
  409.                             if(seatCheck[rs][cs] == 'x'){
  410.                                 taken = 1;
  411.                                 break;
  412.                             }
  413.                             else
  414.                             {
  415.                                 seatCheck[rs][cs] = 'x';
  416.                                 cout<<"Your seat number is "<<addnode->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
  417.                                 taken = 0;
  418.                             }
  419.                         }
  420.                     }
  421.                 }
  422.             }while(taken == 1);
  423.            
  424.         }
  425.  
  426.         else{
  427.             cout<<endl;
  428.             cout<<"Your seat will be chosen randomly. . ."<<endl;
  429.             do{
  430.             taken=0;
  431.             cout<<"Man";
  432.             srand(time(0));
  433.             addnode->sitNum = (rand() % 20) + 1;
  434.            
  435.             //---SEARCHING ROWS AND COLUMNS--------------
  436.  
  437.             for(int rs=0; rs<5; rs++){
  438.                 for(int cs=0; cs<4; cs++){
  439.                     if(addnode->seat[rs][cs] == addnode->sitNum){
  440.                         if(seatCheck[rs][cs] == 'x'){
  441.                                 taken = 1;
  442.                                 break;
  443.                             }
  444.                         else
  445.                             {
  446.                                 seatCheck[rs][cs] = 'x';
  447.                                 cout<<"Your seat number is "<<addnode->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
  448.                                 taken = 0;
  449.                             }
  450.                     }
  451.                 }
  452.             }
  453.             }while(taken==1);
  454.  
  455.         }
  456.  
  457.         for(int y=0; y<5; y++){
  458.                     cout<<endl;
  459.                     for(int f=0; f<4; f++){
  460.                         cout<<" "<<seatCheck[y][f];
  461.                         cout<<"\t";
  462.                     }
  463.                 }
  464.  
  465.         while(temp->nxt !=NULL){
  466.             temp=temp->nxt;
  467.         }
  468.  
  469.         temp->nxt=addnode;
  470.         addnode->nxt = NULL;
  471.  
  472.     }
  473. }
  474.  
  475. //----------------------------------END OF ADD MORNING FLIGHTTTTTTTTTT-----------------------------------------------
  476. //-----------------------------------ADD AFTERNOON FLIGHT-------------------------------------------------
  477. void addPMflight(){
  478.     nodeAfternoon *addnode;
  479.     nodeAfternoon *temp = startPM;
  480.     int ans=2;
  481.  
  482.     if(startPM == NULL){
  483.         addnode = new nodeAfternoon;
  484.        
  485.  
  486.         cout << "Enter your name: " << endl;
  487.         //getline(cin, addnode->name);
  488.         cin.getline(addnode->name, 50);
  489.         cout << "Enter your phone number: " << endl;
  490.         cin >> addnode->phone;
  491.         cin.ignore();
  492.         cout << "Enter your address: " << endl;
  493.         //getline(cin, addnode->address);
  494.         cin.getline(addnode->address, 50);
  495.        
  496.  
  497.         cout << "Would you like to choose your own seat? 1 for yes/ 0 for no" << endl;
  498.         cin >> ans;
  499.         cin.ignore();
  500.  
  501.         //-----DISPLAY AND INITIALIZING SEAT------
  502.         cout<<"This is the seating arrangement. Left and Right sides are window seats.";
  503.         int num=32;
  504.         for(int r=0; r<8; r++){
  505.             cout<<endl;
  506.             for(int c=0; c<4; c++){
  507.                 addnode->seat[r][c]=num;
  508.                 cout<<"\t";
  509.                 num--;
  510.             }
  511.         }
  512.        
  513.         addnode->seat[0][0] = NULL;
  514.         addnode->seat[0][1] = NULL;
  515.  
  516.         for(int x=0; x<8; x++){
  517.             cout<<endl;
  518.             for(int y=0; y<4; y++){
  519.                 cout<<addnode->seat[x][y];
  520.                 cout<<"\t";
  521.             }
  522.         }
  523.  
  524.         for(int q=0; q<8; q++){
  525.             cout<<endl;
  526.             for(int w=0; w<4; w++){
  527.                 seatCheCheck2[q][w]='o';
  528.                 cout<<" "<<seatCheCheck2[q][w];
  529.                 cout<<"\t";
  530.             }
  531.         }
  532.  
  533.         if(ans==1){
  534.             cout<<endl;
  535.             cout<<"Where would you like to seat?"<<endl;
  536.             cin>> addnode->sitNum;
  537.  
  538.             //---SEARCHING ROWS AND COLUMNS--------------
  539.  
  540.             for(int rs=0; rs<8; rs++){
  541.                 for(int cs=0; cs<4; cs++){
  542.                     if(addnode->seat[rs][cs] == addnode->sitNum){
  543.                         cout<<"Your seat number is "<<addnode->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
  544.                         seatCheCheck2[rs][cs] = 'x';
  545.                     }
  546.                 }
  547.             }
  548.  
  549.             system("pause");
  550.         }
  551.  
  552.         else{
  553.             cout<<endl;
  554.             cout<<"Your seat will be chosen randomly. . ."<<endl;
  555.             srand(time(0));
  556.             addnode->sitNum = (rand() % 20) + 1;
  557.            
  558.             //---SEARCHING ROWS AND COLUMNS--------------
  559.  
  560.             for(int rs=0; rs<8; rs++){
  561.                 for(int cs=0; cs<4; cs++){
  562.                     if(addnode->seat[rs][cs] == addnode->sitNum){
  563.                         cout<<"Your seat number is "<<addnode->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
  564.                         seatCheCheck2[rs][cs] = 'x';
  565.                     }
  566.                 }
  567.             }
  568.  
  569.         }
  570.  
  571.         addnode->nxt=NULL;
  572.         startPM=addnode;
  573.     }
  574.  
  575.     else{
  576.         addnode = new nodeAfternoon;
  577.         int taken;
  578.  
  579.         taken=0;
  580.  
  581.         for(int d=0; d<8; d++){
  582.             cout<<endl;
  583.             for(int t=0; t<4; t++){
  584.                 cout<<" "<<seatCheCheck2[d][t];
  585.                 cout<<"\t";
  586.             }
  587.         }
  588.  
  589.         cout << "Enter your name: " << endl;
  590.     //  getline(cin, addnode->name);
  591.         cin.getline(addnode->name, 50);
  592.         cout << "Enter your phone number: " << endl;
  593.         cin >> addnode->phone;
  594.         cin.ignore();
  595.         cout << "Enter your address: " << endl;
  596.         //getline(cin, addnode->address);
  597.         cin.getline(addnode->address, 50);
  598.        
  599.  
  600.         cout << "Would you like to choose your own seat? 1 for yes/ 0 for no" << endl;
  601.         cin >> ans;
  602.         cin.ignore();
  603.  
  604.         //-----DISPLAY AND INITIALIZING SEAT------
  605.         cout<<"This is the seating arrangement. Left and Right sides are window seats.";
  606.         int num=32;
  607.         for(int r=0; r<8; r++){
  608.             cout<<endl;
  609.             for(int c=0; c<4; c++){
  610.                 addnode->seat[r][c]=num;
  611.                 cout<<"\t";
  612.                 num--;
  613.             }
  614.         }
  615.        
  616.         addnode->seat[0][0] = NULL;
  617.         addnode->seat[0][1] = NULL;
  618.  
  619.         for(int z=0; z<8; z++){
  620.             cout<<endl;
  621.             for(int w=0; w<4; w++){
  622.                 cout<<addnode->seat[z][w];
  623.                 cout<<"\t";
  624.             }
  625.         }
  626.        
  627.         if(ans==1){
  628.            
  629.             do{
  630.                 if(taken==0)
  631.                     cout<<"Where would you like to seat?"<<endl;
  632.                 else
  633.                     cout<<"The seat is already taken. Choose another seat."<<endl;
  634.                 cin>>addnode->sitNum;
  635.  
  636.                
  637.                 //---SEARCHING ROWS AND COLUMNS--------------
  638.  
  639.  
  640.                 for(int rs=0; rs<8; rs++){
  641.                     for(int cs=0; cs<4; cs++){
  642.                         if(addnode->seat[rs][cs] == addnode->sitNum){
  643.                             if(seatCheCheck2[rs][cs] == 'x'){
  644.                                 taken = 1;
  645.                                 break;
  646.                             }
  647.                             else
  648.                             {
  649.                                 seatCheCheck2[rs][cs] = 'x';
  650.                                 cout<<"Your seat number is "<<addnode->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
  651.                                 taken = 0;
  652.                             }
  653.                         }
  654.                     }
  655.                 }
  656.             }while(taken == 1);
  657.            
  658.         }
  659.  
  660.         else{
  661.             cout<<endl;
  662.             cout<<"Your seat will be chosen randomly. . ."<<endl;
  663.             do{
  664.             taken=0;
  665.             srand(time(0));
  666.             addnode->sitNum = (rand() % 20) + 1;
  667.            
  668.             //---SEARCHING ROWS AND COLUMNS--------------
  669.  
  670.             for(int rs=0; rs<8; rs++){
  671.                 for(int cs=0; cs<4; cs++){
  672.                     if(addnode->seat[rs][cs] == addnode->sitNum){
  673.                         if(seatCheCheck2[rs][cs] == 'x'){
  674.                                 taken = 1;
  675.                                 break;
  676.                             }
  677.                         else
  678.                             {
  679.                                 seatCheCheck2[rs][cs] = 'x';
  680.                                 cout<<"Your seat number is "<<addnode->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
  681.                                 taken = 0;
  682.                             }
  683.                     }
  684.                 }
  685.             }
  686.             }while(taken==1);
  687.  
  688.         }
  689.  
  690.         for(int y=0; y<8; y++){
  691.                     cout<<endl;
  692.                     for(int f=0; f<4; f++){
  693.                         cout<<" "<<seatCheCheck2[y][f];
  694.                         cout<<"\t";
  695.                     }
  696.                 }
  697.  
  698.         while(temp->nxt !=NULL){
  699.             temp=temp->nxt;
  700.         }
  701.  
  702.         temp->nxt=addnode;
  703.         addnode->nxt = NULL;
  704.  
  705.     }
  706.  
  707. }
  708.  
  709. //----------------------------------CANCEL MORNING FLIGHT--------------------------------------------------
  710. void cancelAMflight(){
  711.     nodeMorning *temp = startAM;
  712.     nodeMorning *temp2 = NULL;
  713.     nodeMorning *cancel = NULL;
  714.     //string name;
  715.     char name[50];
  716.  
  717.     cout<<"Enter passenger's name: ";
  718.     //getline(cin, name);
  719.     cin.getline(name, 50);
  720.  
  721.     while(temp!=NULL){
  722.         if(temp->name == name){
  723.             cancel = temp;
  724.             break;
  725.         }
  726.  
  727.         temp2 = temp;
  728.         temp = temp->nxt;
  729.     }
  730.  
  731.     if(cancel != NULL){
  732.         if(cancel->nxt == NULL){
  733.             if(cancel == startAM)
  734.                 startAM = NULL;
  735.             else
  736.                 temp2->nxt = NULL;
  737.  
  738.             delete cancel;
  739.         }
  740.  
  741.         else{
  742.             if(cancel == startAM){
  743.                 if(cancel->nxt == NULL)
  744.                     startAM = NULL;
  745.                 else
  746.                     startAM = cancel->nxt;
  747.  
  748.                 delete cancel;
  749.             }
  750.  
  751.             else{
  752.                 temp2->nxt = cancel->nxt;
  753.                 delete cancel;
  754.             }
  755.         }
  756.  
  757.         cout<<name<<" is not in the list of passengers anymore. It has been canceled.";
  758.     }
  759.  
  760.     else
  761.         cout<<"We cannot find "<<name<<" in the list of passengers. Sorry.";
  762. }
  763. //-----------------------------CANCEL PM FLIGHT--------------------------------------
  764. void cancelPMflight(){
  765.     nodeAfternoon *temp = startPM;
  766.     nodeAfternoon *temp2 = NULL;
  767.     nodeAfternoon *cancel = NULL;
  768.     string name;
  769.  
  770.     cout<<"Enter passenger's name: ";
  771.     getline(cin, name);
  772.  
  773.     while(temp!=NULL){
  774.         if(temp->name == name){
  775.             cancel = temp;
  776.             break;
  777.         }
  778.  
  779.         temp2 = temp;
  780.         temp = temp->nxt;
  781.     }
  782.  
  783.     if(cancel != NULL){
  784.         if(cancel->nxt == NULL){
  785.             if(cancel == startPM)
  786.                 startPM = NULL;
  787.             else
  788.                 temp2->nxt = NULL;
  789.  
  790.             delete cancel;
  791.         }
  792.  
  793.         else{
  794.             if(cancel == startPM){
  795.                 if(cancel->nxt == NULL)
  796.                     startPM = NULL;
  797.                 else
  798.                     startPM = cancel->nxt;
  799.  
  800.                 delete cancel;
  801.             }
  802.  
  803.             else{
  804.                 temp2->nxt = cancel->nxt;
  805.                 delete cancel;
  806.             }
  807.         }
  808.  
  809.         cout<<name<<" is not in the list of passengers anymore. It has been canceled.";
  810.     }
  811.  
  812.     else
  813.         cout<<"We cannot find "<<name<<" in the list of passengers. Sorry.";
  814. }
  815.  
  816. //----------------------------------DISPLAYING MORNING FLIGHT-----------------------------------------------------------
  817. void displayAMflight(){
  818.     nodeMorning *scanner = startAM;
  819.     while(scanner != NULL)
  820.     {
  821.         cout << scanner->name << endl;
  822.         cout << scanner->phone << endl;
  823.         cout << scanner->address << endl;
  824.         cout << scanner->sitNum << endl;
  825.         cout << endl;
  826.  
  827.         scanner=scanner->nxt;
  828.     }
  829.  
  830.     system("pause");
  831. }
  832.  
  833. //------------------------------------DISPLAY END-----------------------------------------------------------------------
  834.  
  835. void displayPMflight(){
  836.     nodeAfternoon *scanner = startPM;
  837.     while(scanner != NULL)
  838.     {
  839.         cout << scanner->name << endl;
  840.         cout << scanner->phone << endl;
  841.         cout << scanner->address << endl;
  842.         cout << scanner->sitNum << endl;
  843.         cout << endl;
  844.  
  845.         scanner=scanner->nxt;
  846.     }
  847.  
  848.     system("pause");
  849. }
  850.  
  851. //---------------------------------CHANGE AM FLIGHT---------------------------------------
  852. void changeAMflight(){
  853.     nodeMorning *temp = startAM;
  854.     nodeMorning *tempOrig = startAM;
  855.     nodeMorning *temp2 = startAM;
  856.     nodeMorning *change = NULL;
  857.     string name;
  858.     int ans;
  859.     int taken;
  860.     taken =0;
  861.  
  862.     cout<<"Enter passenger name: ";
  863.     getline(cin, name);
  864.  
  865.     while(temp!=NULL){
  866.         if(temp->name == name){
  867.             change = temp;
  868.             tempOrig = temp;
  869.             break;
  870.         }
  871.         temp=temp->nxt;
  872.     }
  873.  
  874.     if(change != NULL){
  875.         cout<<"Your original seat is on "<<temp->sitNum<<"."<<endl;
  876.  
  877.         cout<<"Would you like to choose your seat on your own? 1 for yes, 0 for no: ";
  878.         cin>> ans;
  879.         cin.ignore();
  880.  
  881.                 //-----DISPLAY AND INITIALIZING SEAT------
  882.             cout<<"This is the seating arrangement. Left and Right sides are window seats.";
  883.             int num=20;
  884.             for(int r=0; r<5; r++){
  885.                 cout<<endl;
  886.                 for(int c=0; c<4; c++){
  887.                     temp2->seat[r][c]=num;
  888.                     cout<<" "<<temp2->seat[r][c];
  889.                     cout<<"\t";
  890.                     num--;
  891.                 }
  892.             }
  893.  
  894.             for(int rc=0; rc<5; rc++){
  895.                 for(int cc=0; cc<4; cc++){
  896.                     if(temp->seat[rc][cc] == temp->sitNum)
  897.                         seatCheck[rc][cc] = 'o';
  898.                 }
  899.             }
  900.  
  901.             for(int y=0; y<5; y++){
  902.                 cout<<endl;
  903.                 for(int f=0; f<4; f++){
  904.                         cout<<" "<<seatCheck[y][f];
  905.                         cout<<"\t";
  906.                 }
  907.             }
  908.            
  909.             cout<<endl;
  910.             if(ans==1){
  911.                
  912.                 do{
  913.                     if(taken==0)
  914.                         cout<<"Where would you like to seat?"<<endl;
  915.                     else
  916.                         cout<<"The seat is already taken. Choose another seat."<<endl;
  917.                     cin>>change->sitNum;
  918.  
  919.                    
  920.                     //---SEARCHING ROWS AND COLUMNS--------------
  921.  
  922.  
  923.                     for(int rs=0; rs<5; rs++){
  924.                         for(int cs=0; cs<4; cs++){
  925.                             if(temp2->seat[rs][cs] == change->sitNum){
  926.                                 if(seatCheck[rs][cs] == 'x'){
  927.                                     taken = 1;
  928.                                     break;
  929.                                 }
  930.                                 else
  931.                                 {
  932.                                     seatCheck[rs][cs] = 'x';
  933.                                     cout<<"Your seat number is "<<change->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
  934.                                     taken = 0;
  935.                                 }
  936.                             }
  937.                         }
  938.                     }
  939.                 }while(taken == 1);
  940.                
  941.             }
  942.  
  943.             else{
  944.                 cout<<endl;
  945.                 cout<<"Your seat will be chosen randomly. . ."<<endl;
  946.                 do{
  947.                 taken=0;
  948.                 srand(time(0));
  949.                 change->sitNum = (rand() % 20) + 1;
  950.                
  951.                 //---SEARCHING ROWS AND COLUMNS--------------
  952.  
  953.                 for(int rs=0; rs<5; rs++){
  954.                     for(int cs=0; cs<4; cs++){
  955.                         if(temp2->seat[rs][cs] == change->sitNum){
  956.                             if(seatCheck[rs][cs] == 'x'){
  957.                                     taken = 1;
  958.                                     break;
  959.                                 }
  960.                             else
  961.                                 {
  962.                                     seatCheck[rs][cs] = 'x';
  963.                                     cout<<"Your seat number is "<<change->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
  964.                                     taken = 0;
  965.                                 }
  966.                         }
  967.                     }
  968.                 }
  969.                 }while(taken==1);
  970.  
  971.             }
  972.             cout<<"sjgdsjhgfjhsdgjshg"<<endl;
  973.             cout<<temp->sitNum;
  974.             cout<<endl;
  975.  
  976.             for(int h=0; h<5; h++){
  977.                 cout<<endl;
  978.                 for(int l=0; l<4; l++){
  979.                         cout<<" "<<seatCheck[h][l];
  980.                         cout<<"\t";
  981.                 }
  982.             }
  983.     }
  984.  
  985.     else
  986.         cout<<"We cannot find "<<name<<" in the list of passengers. Sorry.";       
  987. }
  988.  
  989. void changePMflight(){
  990.     nodeAfternoon *temp = startPM;
  991.     nodeAfternoon *tempOrig = startPM;
  992.     nodeAfternoon *temp2 = startPM;
  993.     nodeAfternoon *change = NULL;
  994.     string name;
  995.     int ans;
  996.     int taken;
  997.     taken =0;
  998.  
  999.     cout<<"Enter passenger name: ";
  1000.     getline(cin, name);
  1001.  
  1002.     while(temp!=NULL){
  1003.         if(temp->name == name){
  1004.             change = temp;
  1005.             tempOrig = temp;
  1006.             break;
  1007.         }
  1008.         temp=temp->nxt;
  1009.     }
  1010.  
  1011.     if(change != NULL){
  1012.         cout<<"Your original seat is on "<<temp->sitNum<<"."<<endl;
  1013.  
  1014.         cout<<"Would you like to choose your seat on your own? 1 for yes, 0 for no: ";
  1015.         cin>> ans;
  1016.         cin.ignore();
  1017.  
  1018.         //-----DISPLAY AND INITIALIZING SEAT------
  1019.         cout<<"This is the seating arrangement. Left and Right sides are window seats.";
  1020.         int num=32;
  1021.         for(int r=0; r<8; r++){
  1022.             cout<<endl;
  1023.             for(int c=0; c<4; c++){
  1024.                 temp->seat[r][c]=num;
  1025.                 cout<<"\t";
  1026.                 num--;
  1027.             }
  1028.         }
  1029.        
  1030.         temp->seat[0][0] = NULL;
  1031.         temp->seat[0][1] = NULL;
  1032.  
  1033.         for(int x=0; x<8; x++){
  1034.             cout<<endl;
  1035.             for(int y=0; y<4; y++){
  1036.                 cout<<temp->seat[x][y];
  1037.                 cout<<"\t";
  1038.             }
  1039.         }
  1040.  
  1041.             for(int rc=0; rc<5; rc++){
  1042.                 for(int cc=0; cc<4; cc++){
  1043.                     if(temp->seat[rc][cc] == temp->sitNum)
  1044.                         seatCheCheck2[rc][cc] = 'o';
  1045.                 }
  1046.             }
  1047.  
  1048.             for(int y=0; y<8; y++){
  1049.                 cout<<endl;
  1050.                 for(int f=0; f<4; f++){
  1051.                         cout<<" "<<seatCheCheck2[y][f];
  1052.                         cout<<"\t";
  1053.                 }
  1054.             }
  1055.            
  1056.             cout<<endl;
  1057.             if(ans==1){
  1058.                
  1059.                 do{
  1060.                     if(taken==0)
  1061.                         cout<<"Where would you like to seat?"<<endl;
  1062.                     else
  1063.                         cout<<"The seat is already taken. Choose another seat."<<endl;
  1064.                     cin>>change->sitNum;
  1065.  
  1066.                    
  1067.                     //---SEARCHING ROWS AND COLUMNS--------------
  1068.  
  1069.  
  1070.                     for(int rs=0; rs<8; rs++){
  1071.                         for(int cs=0; cs<4; cs++){
  1072.                             if(temp2->seat[rs][cs] == change->sitNum){
  1073.                                 if(seatCheCheck2[rs][cs] == 'x'){
  1074.                                     taken = 1;
  1075.                                     break;
  1076.                                 }
  1077.                                 else
  1078.                                 {
  1079.                                     seatCheCheck2[rs][cs] = 'x';
  1080.                                     cout<<"Your seat number is "<<change->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
  1081.                                     taken = 0;
  1082.                                 }
  1083.                             }
  1084.                         }
  1085.                     }
  1086.                 }while(taken == 1);
  1087.                
  1088.             }
  1089.  
  1090.             else{
  1091.                 cout<<endl;
  1092.                 cout<<"Your seat will be chosen randomly. . ."<<endl;
  1093.                 do{
  1094.                 taken=0;
  1095.                 srand(time(0));
  1096.                 change->sitNum = (rand() % 20) + 1;
  1097.                
  1098.                 //---SEARCHING ROWS AND COLUMNS--------------
  1099.  
  1100.                 for(int rs=0; rs<8; rs++){
  1101.                     for(int cs=0; cs<4; cs++){
  1102.                         if(temp2->seat[rs][cs] == change->sitNum){
  1103.                             if(seatCheCheck2[rs][cs] == 'x'){
  1104.                                     taken = 1;
  1105.                                     break;
  1106.                                 }
  1107.                             else
  1108.                                 {
  1109.                                     seatCheCheck2[rs][cs] = 'x';
  1110.                                     cout<<"Your seat number is "<<change->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
  1111.                                     taken = 0;
  1112.                                 }
  1113.                         }
  1114.                     }
  1115.                 }
  1116.                 }while(taken==1);
  1117.  
  1118.             }
  1119.             cout<<"sjgdsjhgfjhsdgjshg"<<endl;
  1120.             cout<<temp->sitNum;
  1121.             cout<<endl;
  1122.  
  1123.             for(int h=0; h<8; h++){
  1124.                 cout<<endl;
  1125.                 for(int l=0; l<4; l++){
  1126.                         cout<<" "<<seatCheCheck2[h][l];
  1127.                         cout<<"\t";
  1128.                 }
  1129.             }
  1130.     }
  1131.  
  1132.     else
  1133.         cout<<"We cannot find "<<name<<" in the list of passengers. Sorry.";
  1134. }
  1135.  
  1136. void transferAMflight(){
  1137.     nodeMorning *temp = startAM;
  1138.     nodeMorning *trans = NULL;
  1139.  
  1140.     nodeAfternoon *tempOh = startPM;
  1141.     nodeAfternoon *lala = startPM;
  1142.  
  1143.     string name;
  1144.  
  1145.     cout<<"Enter passenger's name: ";
  1146.     getline(cin, name);
  1147.  
  1148.     while(temp!=NULL){
  1149.         if(temp->name == name){
  1150.             trans = temp;
  1151.             break;
  1152.         }
  1153.         temp=temp->nxt;
  1154.     }
  1155.  
  1156.  
  1157.     while(tempOh->nxt !=NULL){
  1158.             tempOh=tempOh->nxt;
  1159.         }
  1160.  
  1161.         nodeAfternoon *bago = new nodeAfternoon;
  1162.         strcpy(bago->name, trans->name);
  1163.         strcpy(bago->address, trans->address);
  1164.         bago->phone = trans->phone;
  1165.         bago->sitNum = trans->sitNum;
  1166.         //seats;
  1167.  
  1168.         bago->nxt = NULL;
  1169.         tempOh->nxt = bago;
  1170.  
  1171.     for(int rs=0; rs<8; rs++){
  1172.         for(int cs=0; cs<4; cs++){
  1173.             if(lala->seat[rs][cs] == trans->sitNum){
  1174.                 if(seatCheCheck2[rs][cs] == 'o'){
  1175.                     seatCheCheck2[rs][cs] = 'x';
  1176.                     cout<<"Your seat number is "<<trans->sitNum<<". Located in row "<<rs<<" and column "<<cs<<"."<<endl;
  1177.  
  1178.                 }
  1179.  
  1180.                 else{
  1181.                 //  transfer();
  1182.                 }
  1183.             }
  1184.         }
  1185.     }
  1186.        
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.    
  1195.  
  1196.  
  1197. }
Add Comment
Please, Sign In to add comment