M1130 has some kind of error but this programing works on Eee PC T91
This programming assume an airline company's check in system. A user is able to deal with check in and input new customer. The user also fix customer's informaiton when he check in the system. This system serch customer data from reservation list by using their conformation ID numeber. This programming remove user data from reservation list after he checked in and customer data will be written in a Passenger list which it devided by a fright number. A customer data include conform number, customer name,Age,Passport number,Seat,Flight,Gate number, Depart time,Distenation,Bagage number,Bagage Amountv and Status which user is able to write additional informaiton about him.
#include <iostream> #include <iomanip> #include <map> #include <cstring> #include <cstdlib> #include <ostream> #include <fstream> #include <string> #include <sstream> #include <vector> #include <algorithm> #include <ctime> #define HEAD_1 "--------------------------------------------------------------------------------------------------------------------------------------------------------------\n" #define HEAD_2 "Conf# Name Age Passport# Seat Flight Gate Depart Distenation Bagage# Bagage Amount Status \n" using namespace std; class Time { private: time_t rawtime; public: struct tm * timeinfo; Time() { time ( &rawtime ); timeinfo = localtime ( &rawtime ); } }; class Passenger { private: string info; public: string id; map<string, string>::iterator it; map<string,string> data; Passenger() { getPassengerList(); } void getPassengerList() { ifstream file("ResevationList.txt", ios::in); if(!file) { cout << "File was not exist "; } it = data.begin(); while(!file.eof()) { getline(file,id,'\t'); getline(file,info,'\n'); data.insert(it,pair<string,string> (id,info)); it++; } file.close(); } }; class outputData : public Passenger { public: Passenger pa; fstream files; void menu(string &filename,int counter,int i,string &temp,string &id) { writePlist(filename,id,temp); writeRlist(id,temp); } void NewData(string &filename,int counter,int i,string &temp,string &id) { NewDataWriteRlist(filename,id,temp); } void NewDataWriteRlist(string &filename,string& id, string& temp) { int points; fstream files; string temp6; files.open(filename.c_str(),ios::in|ios::out|ios::app); files.seekg(0,ios::end); points = files.tellg(); if(points == 0) { files << "****** PASSENGER LIST FOR " << filename.c_str() << "******** "<<endl; files << endl; files << HEAD_1; files << HEAD_2; files << HEAD_1; } files << id << "\t" << temp <<endl; files.close(); } void writeRlist(string& id, string& temp) { files.open("ResevationList.txt", ios::out); // files.open("ResevationList.txt", ios::out); pa.data.erase(id); for (pa.it = pa.data.begin(); pa.it != pa.data.end(); pa.it++ ) { files << pa.it -> first << "\t" << pa.it -> second << endl; } files.close(); } void writePlist(string &filename,string &id, string &temp) { int points; fstream files; string temp6; files.open(filename.c_str(),ios::in|ios::out|ios::app); files.seekg(0,ios::end); points = files.tellg(); if(points == 0) { files << "****** PASSENGER LIST FOR " << filename.c_str() << "******** "<<endl; files << endl; files << HEAD_1; files << HEAD_2; files << HEAD_1; } files << id <<'\t'<< pa.data.find(id)->second << endl; files.close(); } }; class checkIn : public Passenger { private: char yes_no; outputData op; public: string temp2[13]; string temp; string temp3; int menu; string data2; Passenger pa; string id; size_t point; size_t point2; int counter; int i; string filename; checkIn():Passenger() { getNum(id); printData(id); temp = pa.data.find(id) -> second; fixData(id,filename,counter,i,temp); op.menu(filename,counter,i,temp,id); } void fixData(string &id,string &filename,int &counter, int &i,string &temp) { divData(counter,i,temp); putData(id,counter); while(toupper(getYN()) == 'Y') { menu = getMenu(); getCase(menu); } getFilename(filename); putData(id,counter); } int getMenu() { system("clear"); //system("CLS"); cout << "**** UPDATE MENU ******"<<endl; cout << "1) Flight # " << setw(21) << "4) Destenation "<< endl; cout << "2) Gate # " << setw(18) << "5) Seat # "<< endl; cout << "3) Depart time "<< setw(12) << "6) Status"<<endl; cin >> menu; while((menu < 0)||(menu > 6)) { cout << "***** ERROR *****" << endl; cout << "Invalid number "<< endl; cout << "1) Flight # " << setw(21) << "4) Destenation "<< endl; cout << "2) Gate # " << setw(18) << "5) Seat # "<< endl; cout << "3) Depart time "<< setw(12) << "6) Status"<<endl; cin >> menu; } return menu; } void divData(int &counter,int &i,string &temp) { i=0; for(i;!temp.empty();i++) { point = temp.find('\t'); temp2[i] = temp.substr(0,point); temp = temp.substr(point); point2 = temp.find('\t'); temp = temp.substr(1); } counter = i; } void putData(string &id,int &counter) { int counter3 = 0; system("clear"); //system("CLS"); string newdata; cout << endl; for(counter3;counter3 < counter;counter3++) { newdata.append(temp2[counter3]); newdata.push_back('\t'); } pa.data.erase(id); pa.data.insert(pair<string,string>(id,newdata)); printData(id); } void getFilename(string &filename) { filename.append(temp2[4]); filename.append(".txt"); cout<<filename<<endl; } void getCase(int &menu) { string fix; switch(menu) { cin.ignore(' ',100); case 1: cout << "New flight name : "; cin.ignore(100,'\n'); getline(cin,fix); temp2[4] = fix; break; case 2: cout << "New Gate Number : "; cin.ignore(100,'\n'); getline(cin,fix); temp2[5] = fix; break; case 3: cout << "New Departure Time : "; cin.ignore(100,'\n'); getline(cin,fix); temp2[6] = fix; break; case 4: cout << "New Destination : "; cin.ignore(100,'\n'); getline(cin,fix); temp2[7] = fix; break; case 5: cout << "New Seat Number : "; cin.ignore(100,'\n'); getline(cin,fix); temp2[3] = fix; break; case 6: cout << "New Status : "; cin.ignore(100,'\n'); getline(cin,fix); temp2[11] = fix; break; } } void printData(string &id) { cout << HEAD_1; cout << HEAD_2; cout << HEAD_1; cout << id <<'\t'<< pa.data.find(id) -> second << endl; } void getNum(string &id) { cout << "Enter a Reservation Number : "; cin >> id; try { while(pa.data.find(id) -> second.empty()) { cout << "***** Error ******" <<endl; cout << "System doesn't have requested confarm number "<< endl; cout << "Enter a correct confarm number : "; cin >> id; } } catch(int e) { cout << "*** error *** "<<endl; cout << "System has a unslove error" << endl; cout << "system will log out Start up again "<< endl; cout << "If the same error occured next time " << endl; cout << "please ask software company " << endl; cout << "our technitian will help to solve this prolem "<<endl; } } char getYN() { cout << "Fix data (Yes = Y / No = N)?" <<endl; cin >> yes_no; while((toupper(yes_no) != 'Y')&&(toupper(yes_no) != 'N')) { cout << "Your request is invalid "<<endl; cout << "Fix data (Yes = Y / No = N)?"<<endl; cin >> yes_no; } return yes_no; } }; class createData : public Passenger { private: string paData[12]; outputData op; Passenger pa; string id; public: string filename; string newdata; int counter3; int i; createData() { getData(); getMap(id,newdata); getFilename(filename); op.NewData(filename,counter3,i,newdata,id); } void getFilename(string &filename) { filename.append(paData[5]); filename.append(".txt"); } void getMap(string &id,string &newdata) { i = 12; counter3 = 1; for(counter3;counter3 < i;counter3++) { newdata.append(paData[counter3]); newdata.push_back('\t'); } id = paData[0]; pa.data.insert(pair<string,string>(id,newdata)); } void getData() { string newCost; cout << "***** NEW PASSENGER INFO *****" << endl; cout << "Enter a Conform Numbr : "; cin.ignore(1,' '); getline(cin,newCost); while(newCost.length() != 5) { cout << "***** Error *****"<< endl; cout << "Conf Number must be 5 degit "<< endl; cout << "Try Conf Number again "<<endl; cout << "Conformation Number : "; getline(cin,newCost); } paData[0] = newCost; cout << "Enter a Passenger Name : "; getline(cin,newCost); paData[1] = newCost; cout << "Enter a Age : "; getline(cin,newCost); paData[2] = newCost; cout << "Enter a Passport Number : "; getline(cin,newCost); paData[3] = newCost; cout << "Enter a Seat Number : "; getline(cin,newCost); paData[4] = newCost; cout << "Enter a Fright Number : "; getline(cin,newCost); paData[5] = newCost; cout << "Enter a Gate Number : "; getline(cin,newCost); paData[6] = newCost; cout << "Enter a Dapart : "; getline(cin,newCost); paData[7] = newCost; cout << "Enter a Destination : "; getline(cin,newCost); paData[8] = newCost; cout << "Enter a Bagage Number : "; getline(cin,newCost); paData[9] = newCost; cout << "Enter a Bagage Amount : "; getline(cin,newCost); paData[10] = newCost; cout << "Enter a Status : "; getline(cin,newCost); paData[11] = newCost; } }; int main(void) { int len; string id; string info; int menu; char yes_no; system("clear"); //system("CLS"); /* ifstream file("z.txt"); if(!file) { cout << "File was not exist "; }*/ int counter = 0; do{ Time tm; system("clear"); //system("CLS"); cout << "CHECK IN SYSTEM FOR DOMESTIC / INTERNATIONAL AIRLINE "<<endl; cout << asctime (tm.timeinfo); cout << "***** Menu ******"<<endl; cout << "1) Check In "<< endl; cout << "2) New Customer " << endl; cout << "3) Cancel "<< endl; cin >> menu; while((menu < 0)|| (menu > 4)) { cout << "***** ERROR ******" <<endl; cout << "Menu is chosen by between 1 and 4 "<<endl; cout << "1) Check In "<< endl; cout << "2) New Customer " << endl; cout << "3) Cancel "<< endl; cin >> menu; } system("clear"); //system("CLS"); cout << asctime (tm.timeinfo); if(menu == 1) { checkIn(); } if(menu == 2) { createData(); } if(menu == 3) { break; } }while(menu != 3); return 0; }
Comments
Subscribe to comments
You need to login to post a comment.

UML and Flow chart are available at google doc
UML - https://docs.google.com/drawings/edit?id=1_bhjVBoR4RTq9q4z8hZktu90GkVpf2FfaX51h3JkFKA&hl=en&authkey=CP2r38oB
Flow Chart https://docs.google.com/drawings/edit?id=1_bhjVBoR4RTq9q4z8hZktu90GkVpf2FfaX51h3JkFKA&hl=en&authkey=CP2r38oB
Flow char [correct ver ] https://docs.google.com/drawings/edit?id=1_bhjVBoR4RTq9q4z8hZktu90GkVpf2FfaX51h3JkFKA&hl=en&authkey=CP2r38oB
sorry this one works https://docs.google.com/drawings/edit?id=19U1PfhoR_QKbiFTCsX34z-e40pK6tveYsLG00BIYwcg&hl=en&authkey=CMmbnIYP