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 128 129
|
#include "Register.h"
#include <iostream>
#include <fstream>
#include <string>
Register::Register()
{
//ctor
}
Register::~Register()
{
//dtor
}
void Register::logMenu()
{
int pick = -1;
Register login;
while(pick != 0)
{
cout << "\n Login Menu" << endl;
cout << "================================" << endl;
cout << "[1] - Reserve Tickets" << endl;
cout << "[2] - Edit Ticket's Information" << endl;
cout << "[3] - Cancel a Ticket" << endl;
cout << "[0] - Exit" << endl;
cout << "\nEnter a Menu Number to proceed: ";
cin >> pick;
cin.clear();
fflush(stdin);
switch(pick)
{
case 1:
login.table();
break;
case 2:
login.modify();
break;
case 3:
login.cancel();
break;
case 0:
cout << "Thank you, Please come again!" << endl;
break;
default:
pick = 0;
break;
}
}
}
void Register::table()
{
cout << "\n";
cout << "--------------------------------------------------------------------------------------------------------------------------" << endl;
cout << " Train Name"<<" "<<"Departure Time"<<" "<<"Arrival Time"<<" "<<"Boarding Point"<<" "<<"Destination"<<" "<<"Price"<< endl;
cout << "--------------------------------------------------------------------------------------------------------------------------" << endl;
cout << " Manila Express"<<" "<<"6:00 AM"<<" "<<"6:30 AM"<<" "<<"Baclaran"<<" "<<"Roosevelt"<<" "<<" 50"<< endl;
cout << "--------------------------------------------------------------------------------------------------------------------------" << endl;
cout << " Luzon Express Line"<<" "<<"6:00 AM"<<" "<<"7:00 AM"<<" "<<"Santolan"<<" "<<"Recto"<<" "<<" 75"<< endl;
cout << "--------------------------------------------------------------------------------------------------------------------------" << endl;
cout << " Dakila Train"<<" "<<"7:00 AM"<<" "<<"7:20 AM"<<" "<<"North Avenue"<<" "<<"Taft Avenue"<<" "<<" 40"<< endl;
cout << "--------------------------------------------------------------------------------------------------------------------------" << endl;
cout << " Golden Train"<<" "<<"6:30 AM"<<" "<<"7:00 AM"<<" "<<"Taytay"<<" "<<"Magsaysay Boulevard"<<" "<<"250"<< endl;
cout << "--------------------------------------------------------------------------------------------------------------------------" << endl;
cout << " Puting Rosas"<<" "<<"6:00 AM"<<" "<<"6:20 AM"<<" "<<"Ayala Avenue"<<" "<<"Cembo"<<" "<<" 65"<< endl;
cout << "--------------------------------------------------------------------------------------------------------------------------" << endl;
cout << " Cavite Express"<<" "<<"6:15 AM"<<" "<<"6:45 AM"<<" "<<"Paco"<<" "<<"Naic"<<" "<<" 90"<< endl;
cout << "--------------------------------------------------------------------------------------------------------------------------" << endl;
cout << " Modern Express Train"<<" "<<"8:00 AM"<<" "<<"8:15 AM"<<" "<<"San Jose del Monte"<<" "<<"North Avenue"<<" "<<"120"<< endl;
cout << "--------------------------------------------------------------------------------------------------------------------------" << endl;
cout << " Quezon Express"<<" "<<"6:45 AM"<<" "<<"7:15 AM"<<" "<<"University Avenue"<<" "<<"Lerma"<<" "<<" 35"<< endl;
cout << "--------------------------------------------------------------------------------------------------------------------------" << endl;
cout << " Pulang Kabayo"<<" "<<"7:00 AM"<<" "<<"7:30 AM"<<" "<<"Quirino Highway"<<" "<<"NAIA Terminal 3"<<" "<<" 60"<< endl;
cout << "--------------------------------------------------------------------------------------------------------------------------" << endl;
cout << " PNR Metropolitan Train"<<" "<<"6:00 AM"<<" "<<"6:45 AM"<<" "<<"Tutuban"<<" "<<"IRRI (MSC)"<<" "<<" 30"<< endl;
cout << "--------------------------------------------------------------------------------------------------------------------------" << endl;
reserve();
}
void Register::results(int &x, int &y, int &z)
{
x = y - z;
}
void Register::reserve()
{
string trainName;
int seats;
cout << "\tWhat train would you like to board passenger?" << endl;
cout << "\tPlease input the name of the train below." << endl;
cout << "\tNote: All trains have a maximum boarding capacity of 50." << endl;
cout << "\nTrain Name: ";
getline(cin,trainName);
cout << "Number of Seats: ";
cin >> seats;
int mc[10]= {50, 50, 50, 50, 50 ,50, 50, 50, 50, 50}; // maximum capacity
int ctr[10]= {50, 50, 50, 50, 50 ,50, 50, 50, 50, 50};
int price;
if ((trainName == "Manila Express")||("manila express"))
{
price = 50 * seats;
ctr[0] = mc[0] - seats;
if (mc[0]==0)
{
cout << "\nSorry there are no more seats available on the Manila Express." << endl;
cout << ctr[0];
}
else
{
cout << "\nYou have successfully purchased " << seats << " tickets for the Manila express! See you on board!" << endl;
cout << ctr[0];
}
}
else
{
cout << "Wrong Input!" << endl;
}
}
| |