Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- #include <stdlib.h>
- struct nodeMorning{
- // string name;
- char name[50];
- // string address;
- char address[50];
- int phone;
- int sitNum;
- int seat[5][4];
- nodeMorning *nxt;
- };
- char seatCheck[5][4];
- struct nodeAfternoon{
- //string name;
- char name[50];
- // string address;
- char address[50];
- int phone;
- int sitNum;
- int seat[8][4];
- nodeAfternoon *nxt;
- };
- char seatCheCheck2 [8][4];
- void transfer(char[][4], nodeMorning[][4]);
- void bookFlightMenu(); //check
- void cancelFlightMenu(); //check
- void displayFlightMenu(); //check
- void transferFlightMenu(); //check
- void changeSeatMenu(); //check
- void cancelMornFlight();
- void addAMflight(); //check
- void addPMflight(); //check
- void cancelAMflight(); //check
- void cancelPMflight(); //check
- void displayAMflight(); //check
- void displayPMflight(); //check
- void transferAMflight();
- void transferPMflight();
- void changeAMflight(); //check
- void changePMflight(); //done, still haven't check
- nodeMorning *startAM = NULL;
- nodeAfternoon *startPM = NULL;
- //--------------------------------------MAIN------------------------------------------
- void main(){
- int choice = 0;
- do{
- system("CLS");
- cout << "MENU: " << endl;
- cout << "[1] Book Flight" << endl;
- cout << "[2] Cancel Flight" << endl;
- cout << "[3] Display Passenger List" << endl;
- cout << "[4] Transfer Flights" << endl;
- cout << "[5] Change Seat Assignment" << endl;
- cout << "[6] Morning Flight Cancelled" << endl;
- cout << "[7] Exit" << endl;
- cout << "What do you want to do? : " << endl;
- cin >> choice;
- cin.ignore();
- switch(choice){
- case 1: bookFlightMenu();
- break;
- case 2: cancelFlightMenu();
- break;
- case 3: displayFlightMenu();
- break;
- case 4: transferFlightMenu();
- break;
- case 5: changeSeatMenu();
- break;
- case 6: cancelMornFlight();
- break;
- case 7: cout << "Thank you!" << endl;
- break;
- }
- }while(choice!=7);
- }
- //----------------------------------------CLOSE MAIN--------------------------------------------------
- //-----------------------------------------BOOK FLIGHT MENU-------------------------------------
- void bookFlightMenu(){
- int choice = 0;
- do{
- system("CLS");
- cout << "BOOKFLIGHT MENU: " << endl;
- cout << "[1] Morning Flight" << endl;
- cout << "[2] Afternoon Flight" << endl;
- cout << "[3] Go back to Main Menu" << endl;
- cout << "Which do you prefer? : " << endl;
- cin >> choice;
- cin.ignore();
- switch(choice){
- case 1: addAMflight();
- system("PAUSE");
- break;
- case 2: addPMflight();
- system("PAUSE");
- break;
- case 3: cout << "Thank you!" << endl;
- system("PAUSE");
- break;
- }
- }while(choice!=3);
- }
- //-----------------------------------CANCEL FLIGHT MENU------------------------------------------
- void cancelFlightMenu(){ //delete
- int choice = 0;
- do{
- system("CLS");
- cout << "CANCEL FLIGHT MENU: " << endl;
- cout << "[1] Morning Flight" << endl;
- cout << "[2] Afternoon Flight" << endl;
- cout << "[3] Go back to Main Menu" << endl;
- cout << "Cancel Flight? : " << endl;
- cin >> choice;
- cin.ignore();
- switch(choice){
- case 1: cancelAMflight();
- system("PAUSE");
- break;
- case 2: cancelPMflight();
- system("PAUSE");
- break;
- case 3: cout << "Thank you!" << endl;
- break;
- }
- }while(choice!=3);
- }
- //-----------------------------DISPLAY FLIGHT MENU-----------------------------------------
- void displayFlightMenu(){
- int choice = 0;
- do{
- system("CLS");
- cout << "Display FLIGHT MENU: " << endl;
- cout << "[1] Morning Flight" << endl;
- cout << "[2] Afternoon Flight" << endl;
- cout << "[3] Go back to Main Menu" << endl;
- cout << "Display Flight? : " << endl;
- cin >> choice;
- cin.ignore();
- switch(choice){
- case 1: displayAMflight();
- break;
- case 2: displayPMflight();
- break;
- case 3: cout << "Thank you!" << endl;
- break;
- }
- }while(choice!=3);
- }
- //-------------------------CANCEL MORNING FLIGHT ----------------------------------
- void cancelMornFlight(){
- }
- void transferFlightMenu(){
- int choice = 0;
- do{
- system("CLS");
- cout << "TRANSFER FLIGHT MENU: " << endl;
- cout << "[1] From Morning Flight to Afternoon Flight" << endl;
- cout << "[2] From Afternoon Flight to Morning Flight" << endl;
- cout << "[3] Go back to Main Menu" << endl;
- cout << "Transfer Flight? : " << endl;
- cin >> choice;
- cin.ignore();
- switch(choice){
- case 1: transferAMflight();
- system("pause");
- break;
- // case 2: transferPMflight();
- break;
- // case 3: cout << "Thank you!" << endl;
- break;
- }
- }while(choice!=3);
- }
- void changeSeatMenu(){
- int choice = 0;
- do{
- system("CLS");
- cout << "CHANGE SEAT MENU: " << endl;
- cout << "[1] From Morning Flight" << endl;
- cout << "[2] From Afternoon Flight" << endl;
- cout << "[3] Go back to Main Menu" << endl;
- cout << "Change Seats? : " << endl;
- cin >> choice;
- cin.ignore();
- switch(choice){
- case 1: changeAMflight();
- system("pause");
- break;
- // case 2: changePMflight();
- break;
- // case 3: cout << "Thank you!" << endl;
- break;
- }
- }while(choice!=3);
- }
- //-------------------------ADD MORNING FLIGHT-----------------------------------------
- void addAMflight(){
- nodeMorning *addnode;
- nodeMorning *temp = startAM;
- int ans=2;
- if(startAM == NULL){
- addnode = new nodeMorning;
- cout << "Enter your name: " << endl;
- // getline(cin, addnode->name);
- cin.getline(addnode->name, 50);
- cout << "Enter your phone number: " << endl;
- cin >> addnode->phone;
- cin.ignore();
- cout << "Enter your address: " << endl;
- // getline(cin, addnode->address);
- cin.getline(addnode->address, 50);
- cout << "Would you like to choose your own seat? 1 for yes/ 0 for no" << endl;
- cin >> ans;
- cin.ignore();
- //-----DISPLAY AND INITIALIZING SEAT------
- cout<<"This is the seating arrangement. Left and Right sides are window seats.";
- int num=20;
- for(int r=0; r<5; r++){
- cout<<endl;
- for(int c=0; c<4; c++){
- addnode->seat[r][c]=num;
- cout<<" "<<addnode->seat[r][c];
- cout<<"\t";
- num--;
- }
- }
- for(int q=0; q<5; q++){
- cout<<endl;
- for(int w=0; w<4; w++){
- seatCheck[q][w]='o';
- cout<<" "<<seatCheck[q][w];
- cout<<"\t";
- }
- }
- if(ans==1){
- cout<<endl;
- cout<<"Where would you like to seat?"<<endl;
- cin>> addnode->sitNum;
- //---SEARCHING ROWS AND COLUMNS--------------
- for(int rs=0; rs<5; rs++){
- for(int cs=0; cs<4; cs++){
- if(addnode->seat[rs][cs] == addnode->sitNum){
- cout<<"Your seat number is "<<addnode->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
- seatCheck[rs][cs] = 'x';
- }
- }
- }
- system("pause");
- }
- else{
- cout<<endl;
- cout<<"Your seat will be chosen randomly. . ."<<endl;
- srand(time(0));
- addnode->sitNum = (rand() % 20) + 1;
- //---SEARCHING ROWS AND COLUMNS--------------
- for(int rs=0; rs<5; rs++){
- for(int cs=0; cs<4; cs++){
- if(addnode->seat[rs][cs] == addnode->sitNum){
- cout<<"Your seat number is "<<addnode->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
- seatCheck[rs][cs] = 'x';
- }
- }
- }
- }
- addnode->nxt=NULL;
- startAM=addnode;
- }
- else{
- addnode = new nodeMorning;
- int taken;
- taken=0;
- for(int d=0; d<5; d++){
- cout<<endl;
- for(int t=0; t<4; t++){
- cout<<" "<<seatCheck[d][t];
- cout<<"\t";
- }
- }
- cout << "Enter your name: " << endl;
- //getline(cin, addnode->name);
- cin.getline(addnode->name, 50);
- cout << "Enter your phone number: " << endl;
- cin >> addnode->phone;
- cin.ignore();
- cout << "Enter your address: " << endl;
- //getline(cin, addnode->address);
- cin.getline(addnode->address, 50);
- cout << "Would you like to choose your own seat? 1 for yes/ 0 for no" << endl;
- cin >> ans;
- cin.ignore();
- //-----DISPLAY AND INITIALIZING SEAT------
- cout<<"This is the seating arrangement. Left and Right sides are window seats.";
- int num=20;
- for(int r=0; r<5; r++){
- cout<<endl;
- for(int c=0; c<4; c++){
- addnode->seat[r][c]=num;
- cout<<" "<<addnode->seat[r][c];
- cout<<"\t";
- num--;
- }
- }
- if(ans==1){
- do{
- if(taken==0)
- cout<<"Where would you like to seat?"<<endl;
- else
- cout<<"The seat is already taken. Choose another seat."<<endl;
- cin>>addnode->sitNum;
- //---SEARCHING ROWS AND COLUMNS--------------
- for(int rs=0; rs<5; rs++){
- for(int cs=0; cs<4; cs++){
- if(addnode->seat[rs][cs] == addnode->sitNum){
- if(seatCheck[rs][cs] == 'x'){
- taken = 1;
- break;
- }
- else
- {
- seatCheck[rs][cs] = 'x';
- cout<<"Your seat number is "<<addnode->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
- taken = 0;
- }
- }
- }
- }
- }while(taken == 1);
- }
- else{
- cout<<endl;
- cout<<"Your seat will be chosen randomly. . ."<<endl;
- do{
- taken=0;
- cout<<"Man";
- srand(time(0));
- addnode->sitNum = (rand() % 20) + 1;
- //---SEARCHING ROWS AND COLUMNS--------------
- for(int rs=0; rs<5; rs++){
- for(int cs=0; cs<4; cs++){
- if(addnode->seat[rs][cs] == addnode->sitNum){
- if(seatCheck[rs][cs] == 'x'){
- taken = 1;
- break;
- }
- else
- {
- seatCheck[rs][cs] = 'x';
- cout<<"Your seat number is "<<addnode->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
- taken = 0;
- }
- }
- }
- }
- }while(taken==1);
- }
- for(int y=0; y<5; y++){
- cout<<endl;
- for(int f=0; f<4; f++){
- cout<<" "<<seatCheck[y][f];
- cout<<"\t";
- }
- }
- while(temp->nxt !=NULL){
- temp=temp->nxt;
- }
- temp->nxt=addnode;
- addnode->nxt = NULL;
- }
- }
- //----------------------------------END OF ADD MORNING FLIGHTTTTTTTTTT-----------------------------------------------
- //-----------------------------------ADD AFTERNOON FLIGHT-------------------------------------------------
- void addPMflight(){
- nodeAfternoon *addnode;
- nodeAfternoon *temp = startPM;
- int ans=2;
- if(startPM == NULL){
- addnode = new nodeAfternoon;
- cout << "Enter your name: " << endl;
- //getline(cin, addnode->name);
- cin.getline(addnode->name, 50);
- cout << "Enter your phone number: " << endl;
- cin >> addnode->phone;
- cin.ignore();
- cout << "Enter your address: " << endl;
- //getline(cin, addnode->address);
- cin.getline(addnode->address, 50);
- cout << "Would you like to choose your own seat? 1 for yes/ 0 for no" << endl;
- cin >> ans;
- cin.ignore();
- //-----DISPLAY AND INITIALIZING SEAT------
- cout<<"This is the seating arrangement. Left and Right sides are window seats.";
- int num=32;
- for(int r=0; r<8; r++){
- cout<<endl;
- for(int c=0; c<4; c++){
- addnode->seat[r][c]=num;
- cout<<"\t";
- num--;
- }
- }
- addnode->seat[0][0] = NULL;
- addnode->seat[0][1] = NULL;
- for(int x=0; x<8; x++){
- cout<<endl;
- for(int y=0; y<4; y++){
- cout<<addnode->seat[x][y];
- cout<<"\t";
- }
- }
- for(int q=0; q<8; q++){
- cout<<endl;
- for(int w=0; w<4; w++){
- seatCheCheck2[q][w]='o';
- cout<<" "<<seatCheCheck2[q][w];
- cout<<"\t";
- }
- }
- if(ans==1){
- cout<<endl;
- cout<<"Where would you like to seat?"<<endl;
- cin>> addnode->sitNum;
- //---SEARCHING ROWS AND COLUMNS--------------
- for(int rs=0; rs<8; rs++){
- for(int cs=0; cs<4; cs++){
- if(addnode->seat[rs][cs] == addnode->sitNum){
- cout<<"Your seat number is "<<addnode->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
- seatCheCheck2[rs][cs] = 'x';
- }
- }
- }
- system("pause");
- }
- else{
- cout<<endl;
- cout<<"Your seat will be chosen randomly. . ."<<endl;
- srand(time(0));
- addnode->sitNum = (rand() % 20) + 1;
- //---SEARCHING ROWS AND COLUMNS--------------
- for(int rs=0; rs<8; rs++){
- for(int cs=0; cs<4; cs++){
- if(addnode->seat[rs][cs] == addnode->sitNum){
- cout<<"Your seat number is "<<addnode->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
- seatCheCheck2[rs][cs] = 'x';
- }
- }
- }
- }
- addnode->nxt=NULL;
- startPM=addnode;
- }
- else{
- addnode = new nodeAfternoon;
- int taken;
- taken=0;
- for(int d=0; d<8; d++){
- cout<<endl;
- for(int t=0; t<4; t++){
- cout<<" "<<seatCheCheck2[d][t];
- cout<<"\t";
- }
- }
- cout << "Enter your name: " << endl;
- // getline(cin, addnode->name);
- cin.getline(addnode->name, 50);
- cout << "Enter your phone number: " << endl;
- cin >> addnode->phone;
- cin.ignore();
- cout << "Enter your address: " << endl;
- //getline(cin, addnode->address);
- cin.getline(addnode->address, 50);
- cout << "Would you like to choose your own seat? 1 for yes/ 0 for no" << endl;
- cin >> ans;
- cin.ignore();
- //-----DISPLAY AND INITIALIZING SEAT------
- cout<<"This is the seating arrangement. Left and Right sides are window seats.";
- int num=32;
- for(int r=0; r<8; r++){
- cout<<endl;
- for(int c=0; c<4; c++){
- addnode->seat[r][c]=num;
- cout<<"\t";
- num--;
- }
- }
- addnode->seat[0][0] = NULL;
- addnode->seat[0][1] = NULL;
- for(int z=0; z<8; z++){
- cout<<endl;
- for(int w=0; w<4; w++){
- cout<<addnode->seat[z][w];
- cout<<"\t";
- }
- }
- if(ans==1){
- do{
- if(taken==0)
- cout<<"Where would you like to seat?"<<endl;
- else
- cout<<"The seat is already taken. Choose another seat."<<endl;
- cin>>addnode->sitNum;
- //---SEARCHING ROWS AND COLUMNS--------------
- for(int rs=0; rs<8; rs++){
- for(int cs=0; cs<4; cs++){
- if(addnode->seat[rs][cs] == addnode->sitNum){
- if(seatCheCheck2[rs][cs] == 'x'){
- taken = 1;
- break;
- }
- else
- {
- seatCheCheck2[rs][cs] = 'x';
- cout<<"Your seat number is "<<addnode->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
- taken = 0;
- }
- }
- }
- }
- }while(taken == 1);
- }
- else{
- cout<<endl;
- cout<<"Your seat will be chosen randomly. . ."<<endl;
- do{
- taken=0;
- srand(time(0));
- addnode->sitNum = (rand() % 20) + 1;
- //---SEARCHING ROWS AND COLUMNS--------------
- for(int rs=0; rs<8; rs++){
- for(int cs=0; cs<4; cs++){
- if(addnode->seat[rs][cs] == addnode->sitNum){
- if(seatCheCheck2[rs][cs] == 'x'){
- taken = 1;
- break;
- }
- else
- {
- seatCheCheck2[rs][cs] = 'x';
- cout<<"Your seat number is "<<addnode->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
- taken = 0;
- }
- }
- }
- }
- }while(taken==1);
- }
- for(int y=0; y<8; y++){
- cout<<endl;
- for(int f=0; f<4; f++){
- cout<<" "<<seatCheCheck2[y][f];
- cout<<"\t";
- }
- }
- while(temp->nxt !=NULL){
- temp=temp->nxt;
- }
- temp->nxt=addnode;
- addnode->nxt = NULL;
- }
- }
- //----------------------------------CANCEL MORNING FLIGHT--------------------------------------------------
- void cancelAMflight(){
- nodeMorning *temp = startAM;
- nodeMorning *temp2 = NULL;
- nodeMorning *cancel = NULL;
- //string name;
- char name[50];
- cout<<"Enter passenger's name: ";
- //getline(cin, name);
- cin.getline(name, 50);
- while(temp!=NULL){
- if(temp->name == name){
- cancel = temp;
- break;
- }
- temp2 = temp;
- temp = temp->nxt;
- }
- if(cancel != NULL){
- if(cancel->nxt == NULL){
- if(cancel == startAM)
- startAM = NULL;
- else
- temp2->nxt = NULL;
- delete cancel;
- }
- else{
- if(cancel == startAM){
- if(cancel->nxt == NULL)
- startAM = NULL;
- else
- startAM = cancel->nxt;
- delete cancel;
- }
- else{
- temp2->nxt = cancel->nxt;
- delete cancel;
- }
- }
- cout<<name<<" is not in the list of passengers anymore. It has been canceled.";
- }
- else
- cout<<"We cannot find "<<name<<" in the list of passengers. Sorry.";
- }
- //-----------------------------CANCEL PM FLIGHT--------------------------------------
- void cancelPMflight(){
- nodeAfternoon *temp = startPM;
- nodeAfternoon *temp2 = NULL;
- nodeAfternoon *cancel = NULL;
- string name;
- cout<<"Enter passenger's name: ";
- getline(cin, name);
- while(temp!=NULL){
- if(temp->name == name){
- cancel = temp;
- break;
- }
- temp2 = temp;
- temp = temp->nxt;
- }
- if(cancel != NULL){
- if(cancel->nxt == NULL){
- if(cancel == startPM)
- startPM = NULL;
- else
- temp2->nxt = NULL;
- delete cancel;
- }
- else{
- if(cancel == startPM){
- if(cancel->nxt == NULL)
- startPM = NULL;
- else
- startPM = cancel->nxt;
- delete cancel;
- }
- else{
- temp2->nxt = cancel->nxt;
- delete cancel;
- }
- }
- cout<<name<<" is not in the list of passengers anymore. It has been canceled.";
- }
- else
- cout<<"We cannot find "<<name<<" in the list of passengers. Sorry.";
- }
- //----------------------------------DISPLAYING MORNING FLIGHT-----------------------------------------------------------
- void displayAMflight(){
- nodeMorning *scanner = startAM;
- while(scanner != NULL)
- {
- cout << scanner->name << endl;
- cout << scanner->phone << endl;
- cout << scanner->address << endl;
- cout << scanner->sitNum << endl;
- cout << endl;
- scanner=scanner->nxt;
- }
- system("pause");
- }
- //------------------------------------DISPLAY END-----------------------------------------------------------------------
- void displayPMflight(){
- nodeAfternoon *scanner = startPM;
- while(scanner != NULL)
- {
- cout << scanner->name << endl;
- cout << scanner->phone << endl;
- cout << scanner->address << endl;
- cout << scanner->sitNum << endl;
- cout << endl;
- scanner=scanner->nxt;
- }
- system("pause");
- }
- //---------------------------------CHANGE AM FLIGHT---------------------------------------
- void changeAMflight(){
- nodeMorning *temp = startAM;
- nodeMorning *tempOrig = startAM;
- nodeMorning *temp2 = startAM;
- nodeMorning *change = NULL;
- string name;
- int ans;
- int taken;
- taken =0;
- cout<<"Enter passenger name: ";
- getline(cin, name);
- while(temp!=NULL){
- if(temp->name == name){
- change = temp;
- tempOrig = temp;
- break;
- }
- temp=temp->nxt;
- }
- if(change != NULL){
- cout<<"Your original seat is on "<<temp->sitNum<<"."<<endl;
- cout<<"Would you like to choose your seat on your own? 1 for yes, 0 for no: ";
- cin>> ans;
- cin.ignore();
- //-----DISPLAY AND INITIALIZING SEAT------
- cout<<"This is the seating arrangement. Left and Right sides are window seats.";
- int num=20;
- for(int r=0; r<5; r++){
- cout<<endl;
- for(int c=0; c<4; c++){
- temp2->seat[r][c]=num;
- cout<<" "<<temp2->seat[r][c];
- cout<<"\t";
- num--;
- }
- }
- for(int rc=0; rc<5; rc++){
- for(int cc=0; cc<4; cc++){
- if(temp->seat[rc][cc] == temp->sitNum)
- seatCheck[rc][cc] = 'o';
- }
- }
- for(int y=0; y<5; y++){
- cout<<endl;
- for(int f=0; f<4; f++){
- cout<<" "<<seatCheck[y][f];
- cout<<"\t";
- }
- }
- cout<<endl;
- if(ans==1){
- do{
- if(taken==0)
- cout<<"Where would you like to seat?"<<endl;
- else
- cout<<"The seat is already taken. Choose another seat."<<endl;
- cin>>change->sitNum;
- //---SEARCHING ROWS AND COLUMNS--------------
- for(int rs=0; rs<5; rs++){
- for(int cs=0; cs<4; cs++){
- if(temp2->seat[rs][cs] == change->sitNum){
- if(seatCheck[rs][cs] == 'x'){
- taken = 1;
- break;
- }
- else
- {
- seatCheck[rs][cs] = 'x';
- cout<<"Your seat number is "<<change->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
- taken = 0;
- }
- }
- }
- }
- }while(taken == 1);
- }
- else{
- cout<<endl;
- cout<<"Your seat will be chosen randomly. . ."<<endl;
- do{
- taken=0;
- srand(time(0));
- change->sitNum = (rand() % 20) + 1;
- //---SEARCHING ROWS AND COLUMNS--------------
- for(int rs=0; rs<5; rs++){
- for(int cs=0; cs<4; cs++){
- if(temp2->seat[rs][cs] == change->sitNum){
- if(seatCheck[rs][cs] == 'x'){
- taken = 1;
- break;
- }
- else
- {
- seatCheck[rs][cs] = 'x';
- cout<<"Your seat number is "<<change->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
- taken = 0;
- }
- }
- }
- }
- }while(taken==1);
- }
- cout<<"sjgdsjhgfjhsdgjshg"<<endl;
- cout<<temp->sitNum;
- cout<<endl;
- for(int h=0; h<5; h++){
- cout<<endl;
- for(int l=0; l<4; l++){
- cout<<" "<<seatCheck[h][l];
- cout<<"\t";
- }
- }
- }
- else
- cout<<"We cannot find "<<name<<" in the list of passengers. Sorry.";
- }
- void changePMflight(){
- nodeAfternoon *temp = startPM;
- nodeAfternoon *tempOrig = startPM;
- nodeAfternoon *temp2 = startPM;
- nodeAfternoon *change = NULL;
- string name;
- int ans;
- int taken;
- taken =0;
- cout<<"Enter passenger name: ";
- getline(cin, name);
- while(temp!=NULL){
- if(temp->name == name){
- change = temp;
- tempOrig = temp;
- break;
- }
- temp=temp->nxt;
- }
- if(change != NULL){
- cout<<"Your original seat is on "<<temp->sitNum<<"."<<endl;
- cout<<"Would you like to choose your seat on your own? 1 for yes, 0 for no: ";
- cin>> ans;
- cin.ignore();
- //-----DISPLAY AND INITIALIZING SEAT------
- cout<<"This is the seating arrangement. Left and Right sides are window seats.";
- int num=32;
- for(int r=0; r<8; r++){
- cout<<endl;
- for(int c=0; c<4; c++){
- temp->seat[r][c]=num;
- cout<<"\t";
- num--;
- }
- }
- temp->seat[0][0] = NULL;
- temp->seat[0][1] = NULL;
- for(int x=0; x<8; x++){
- cout<<endl;
- for(int y=0; y<4; y++){
- cout<<temp->seat[x][y];
- cout<<"\t";
- }
- }
- for(int rc=0; rc<5; rc++){
- for(int cc=0; cc<4; cc++){
- if(temp->seat[rc][cc] == temp->sitNum)
- seatCheCheck2[rc][cc] = 'o';
- }
- }
- for(int y=0; y<8; y++){
- cout<<endl;
- for(int f=0; f<4; f++){
- cout<<" "<<seatCheCheck2[y][f];
- cout<<"\t";
- }
- }
- cout<<endl;
- if(ans==1){
- do{
- if(taken==0)
- cout<<"Where would you like to seat?"<<endl;
- else
- cout<<"The seat is already taken. Choose another seat."<<endl;
- cin>>change->sitNum;
- //---SEARCHING ROWS AND COLUMNS--------------
- for(int rs=0; rs<8; rs++){
- for(int cs=0; cs<4; cs++){
- if(temp2->seat[rs][cs] == change->sitNum){
- if(seatCheCheck2[rs][cs] == 'x'){
- taken = 1;
- break;
- }
- else
- {
- seatCheCheck2[rs][cs] = 'x';
- cout<<"Your seat number is "<<change->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
- taken = 0;
- }
- }
- }
- }
- }while(taken == 1);
- }
- else{
- cout<<endl;
- cout<<"Your seat will be chosen randomly. . ."<<endl;
- do{
- taken=0;
- srand(time(0));
- change->sitNum = (rand() % 20) + 1;
- //---SEARCHING ROWS AND COLUMNS--------------
- for(int rs=0; rs<8; rs++){
- for(int cs=0; cs<4; cs++){
- if(temp2->seat[rs][cs] == change->sitNum){
- if(seatCheCheck2[rs][cs] == 'x'){
- taken = 1;
- break;
- }
- else
- {
- seatCheCheck2[rs][cs] = 'x';
- cout<<"Your seat number is "<<change->sitNum<<". It is located in row "<<rs<<" and in column "<<cs<<".";
- taken = 0;
- }
- }
- }
- }
- }while(taken==1);
- }
- cout<<"sjgdsjhgfjhsdgjshg"<<endl;
- cout<<temp->sitNum;
- cout<<endl;
- for(int h=0; h<8; h++){
- cout<<endl;
- for(int l=0; l<4; l++){
- cout<<" "<<seatCheCheck2[h][l];
- cout<<"\t";
- }
- }
- }
- else
- cout<<"We cannot find "<<name<<" in the list of passengers. Sorry.";
- }
- void transferAMflight(){
- nodeMorning *temp = startAM;
- nodeMorning *trans = NULL;
- nodeAfternoon *tempOh = startPM;
- nodeAfternoon *lala = startPM;
- string name;
- cout<<"Enter passenger's name: ";
- getline(cin, name);
- while(temp!=NULL){
- if(temp->name == name){
- trans = temp;
- break;
- }
- temp=temp->nxt;
- }
- while(tempOh->nxt !=NULL){
- tempOh=tempOh->nxt;
- }
- nodeAfternoon *bago = new nodeAfternoon;
- strcpy(bago->name, trans->name);
- strcpy(bago->address, trans->address);
- bago->phone = trans->phone;
- bago->sitNum = trans->sitNum;
- //seats;
- bago->nxt = NULL;
- tempOh->nxt = bago;
- for(int rs=0; rs<8; rs++){
- for(int cs=0; cs<4; cs++){
- if(lala->seat[rs][cs] == trans->sitNum){
- if(seatCheCheck2[rs][cs] == 'o'){
- seatCheCheck2[rs][cs] = 'x';
- cout<<"Your seat number is "<<trans->sitNum<<". Located in row "<<rs<<" and column "<<cs<<"."<<endl;
- }
- else{
- // transfer();
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment