1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
void main()
{
passenger Seating[240],plane[12];
passenger S1;
int i,z,a,k=300,row,choice2;
char column,choiceone;
char character[100];
string depart;
string arrive;
time_t start; //declaring start as a time function
time (&start);
for(a=1;a<=12;a++)
{
plane[a].seatplan(); //Set the seat plane for each plane
}
for (i=1;i<=100000;i++)
{
S1.menu(); //Display the main manu
cout<<"Which process you want to proceed <1-4>?"<<endl; // choosing which process would like to be proceed
while (true)
{
// Read the user's input
string s;
getline( cin, s );
// Get rid of any trailing whitespace
s.erase( s.find_last_not_of( " \t\v\n\r\f" ) + 1 );
// Convert the user's input into a number, if possible
istringstream ss( s );
ss >> choice2;
// If conversion worked, we're done
if (ss.eof() && (choice2 >= 1) && (choice2 <= 4)) break;
// Else conversion failed. Complain to user.
cout << "Please, enter 1, 2, 3, or 4> " << flush;
}
switch (choice2)
{
case 1: for (z=13;z>=12;z--)
{
Seating[i].Destination_list();
a=Seating[i].decision();
z=a;
}
cout<<"Please wait a while......"<<endl;
S1.loading(3); //hold the program for 3 seconds
system ("cls"); // clear the screen
cin.ignore(1000,'\n');
cout<<"Please enter your details."<<endl;
cout<<"Name : ";
Seating[i].Setname(); //customers enter their names
cout<<"Nationality : ";
Seating[i].Setnation(); //nationality
cout<<"Identity Card/Passport NO. : ";
Seating[i].Seticno(); //IC no./Passport no.
cout<<"Address : ";
Seating[i].Setaddress(); //address
cout<<endl;
Seating[i].select_seat(); //customer select their desired seats
row=Seating[i].Getrow(); //Get the row
column=Seating[i].Getcolumn(); //and column chosen
plane[a].show_seat(row,column); //pass the row and column into function by reference using pointer
cout<<"Please check the details below are correct or not."<<endl;
cout<<"Name : "<<Seating[i].Getname()<<endl; //prints
cout<<"Nationality : "<<Seating[i].Getnation()<<endl; //out
cout<<"Identidy Card/Passport NO. : "<<Seating[i].Geticno()<<endl; //the info
cout<<"Address : "<<Seating[i].Getaddress()<<endl; //entered
Seating[i].decision();
cout<<"Depart At : "<<Seating[i].GetDeparture()<<endl;
cout<<"Arrive At : "<<Seating[i].GetDestination()<<endl;
cout<<"Seat No. : "<<Seating[i].Getrow()<<Seating[i].Getcolumn()<<endl;
cout<<"If correct, press <Y>. If wrong, press <N>. "<<endl; //confirm the info entered is correct or not
cin>>choiceone;
choiceone = static_cast<char>(toupper(choiceone)); //column is converted to uppercase and a temporary copy of type char is made
if (choiceone == 'Y')
{
cout<<"Seat reserved at "<<ctime (&start); //Set the reservation time
Seating[i].Settime(ctime (&start)); //for identical customer
cout<<"Your Reservation Reference No. : "<<i<<endl;
cout<<"Please settle your payment within 1 month. "<<endl;
cout<<"If not, your reservation will be cancelled automatically."<<endl<<endl;
cout<<"Press any character to continue. ";
cin>>character;
}
else
{
i--;
}break;
case 2: cout<<"Enter your reference no."<<endl; //customers check their reservation
cin>>i; //using the provided reference after the
cout<<"Name : "<<Seating[i].Getname()<<endl; //reservatiion made
cout<<"Nationality : "<<Seating[i].Getnation()<<endl;
cout<<"Identidy Card/Passport NO. : "<<Seating[i].Geticno()<<endl;
cout<<"Address : "<<Seating[i].Getaddress()<<endl;
Seating[i].decision();
cout<<"Depart At : "<<Seating[i].GetDeparture()<<endl;
cout<<"Arrive At : "<<Seating[i].GetDestination()<<endl;
cout<<"Seat No. : "<<Seating[i].Getrow()<<Seating[i].Getcolumn()<<endl;
cout<<"Seat reserved time : "<<Seating[i].Gettime()<<endl<<endl;
cout<<"Press any character to continue. ";
cin>>character;
break;
case 3: S1.Destination_list(); //Allow the customers to check the seats availability
a=S1.decision(); //for their desired flight
plane[a].show_seat(k++,k++);
cout<<"Press any character to continue. ";
cin>>character;
break;
case 4: i+=100050; // exits the system
break;
default: i--;
cout<<"Wrong Input. Please Select again. ";
break;
}
S1.loading(2); //hold the system for 2 seconds before proceed to next line
system ("cls"); //clear the system screen
}
}
| |