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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
|
#include <iostream>
#include <conio.h>
#include <fstream>
#include <string>
#include <ctype.h>
using namespace std;
class traval_agen{
public:
friend ifstream& operator >>(ifstream&,traval_agen&);
friend ofstream& operator <<(ofstream&,traval_agen&);
friend ostream& operator <<(ostream&,traval_agen&);
friend istream& operator >>(istream&,traval_agen&);
void display();
void search();
void registration();
private:
string place;
string vehicle;
string board;
string name;
string address;
string date_registration;
string seats;
string days;
char client_number[20];
string client_phone_no;
int total_cost;
};
ifstream& operator >>(ifstream& show,traval_agen& g)
{
getline(show,g.name);
getline(show,g.address);
show.getline(g.client_number,20);
getline(show,g.client_phone_no);
getline(show,g.date_registration);
getline(show,g.place);
getline(show,g.days);
getline(show,g.seats);
getline(show,g.vehicle);
getline(show,g.board);
return show;
}
istream& operator >>(istream& in,traval_agen& g)
{
cout<<"Please enter your Full Name: ";
getline(in,g.name);
cout<<"Please enter your adress: ";
getline(in,g.address);
cout<<"Please Enter Your Diser Id Number: ";
in>>g.client_number;
cout<<"Please enter your Phone Number: ";
in>>g.client_phone_no;
in.ignore();
cout<<"Date Of registration: ";
getline(in,g.date_registration);
cout<<endl<<endl;
cout<<"Enter your Travling Information"<<endl<<endl;
cout<<"Enter Place From where to Where: ";
getline(in,g.place);
cout<<"How many days you want to stay: ";
in>>g.days;
cout<<"How many sets whould you like to Book: ";
in>>g.seats;
in.ignore();
cout<<"Enter The Vehicle Name In which you want to traval: ";
getline(in,g.vehicle);
cout<<"Enter the color of the board: ";
getline(in,g.board);
return in;
}
ofstream& operator <<(ofstream& inputFile,traval_agen& g)
{
inputFile<<"Name:"<<g.name<<endl;
inputFile<<"Adress: "<<g.address<<endl;
inputFile<<"Client No: "<<g.client_number<<endl;
inputFile<<"Client Phone No: "<<g.client_phone_no<<endl;
inputFile<<"Registration Date: "<<g.date_registration<<endl;
inputFile<<"Place: "<<g.place<<endl;
inputFile<<"Days: "<<g.days<<endl;
inputFile<<"Seats: "<<g.seats<<endl;
inputFile<<"Vehicle: "<<g.vehicle<<endl;
inputFile<<"Board: "<<g.board;
return inputFile;
}
ostream& operator <<(ostream& os,traval_agen& i)
{
os<<"Personal Information"<<endl<<endl<<i.name<<endl<<i.address<<endl<<i.client_number<<endl<<i.client_phone_no<<endl<<i.date_registration<<endl<<endl
<<"Trval Information"<<endl<<endl<<i.place<<endl<<i.days<<endl<<i.seats<<endl<<i.vehicle<<endl<<i.board<<endl;
return os;
}
void traval_agen::display()
{
int choice = 0;
cout<<"Users List Is Below"<<endl<<endl;
char user_num_id[25];
int i = 0;
ifstream ids;
ifstream u_num;
u_num.open("user_num.txt");
ids.open("IDS.txt");
u_num>>i;
cout<<endl;
cout<<"Ids "<<"Names"<<endl<<endl;
for(int j = 0;j<i;j++)
{
ids.getline(user_num_id,25,'*');
cout<<user_num_id<<endl;
}
cout<<"To check your Recoard Press 1 To exit press any key: ";
cin>>choice;
ids.close();
u_num.close();
if(choice == 1)
{
system("cls");
search();
}
}
void traval_agen::search()
{
int choice = 0;
char *c;
ifstream show;
char id[20];
cout<<"Please Enter Your Id to display your information: ";
cin>>id;
c = strcat(id,".txt");
show.open(c);
if(!show)
{
system("color 04");
cout<<endl;
cout<<"*************..Recod Not Found..*************"<<endl<<endl;
cout<<"Press Any key to try again: "<<endl;
_getch();
system("color 07");
system("cls");
search();
}
show>>(*this);
cout<<endl<<endl;
cout<<"*************..Recod Found..*************"<<endl<<endl;
cout<<(*this);
cout<<"Total Cost Is: "<<"10,000"<<endl<<endl;
cout<<"To search another Record Press 1 To exit Press Any key: ";
cin>>choice;
show.close();
if(choice == 1)
{
system("cls");
search();
}
}
void traval_agen::registration()
{
cout<<"Enter Your Personal Information"<<endl<<endl;
char id[20];
int i = 0;
ifstream user_num;
ofstream users_num;
ofstream output;
ofstream onputFile;
user_num.open("user_num.txt");
cin.ignore();
output.open("IDS.txt",ios::app);
cin>>(*this);
strcpy(id,this->client_number);
output<<id<<": "<<this->name<<'*';
strcat(id,".txt");
onputFile.open(id,ios::app);
onputFile<<(*this);
cout<<"Total Cost of the traval is: "<<"10,000"<<endl;
cout<<"your Registration Has been submited"<<endl;
user_num>>i;
i++;
users_num.open("user_num.txt");
users_num<<i;
output.close();
onputFile.close();
users_num.close();
user_num.close();
}
int main()
{
int choice = 0;
traval_agen reg;
traval_agen dis;
int i;
cout<<"Select Your Choice"<<endl<<endl;
cout<<"For Registration Press .................... 1"<<endl;
cout<<"For Display Press ......................... 2"<<endl;
cout<<"For Searching Your data Press ............. 3"<<endl;
cout<<"For Exit press .............................6"<<endl<<endl<<endl<<endl;
cout<<"Please Chose your Choice From the Above Menu: ";
cin>>i;
switch(i)
{
case 1:
system("cls");
reg.registration();
break;
case 3:
system("cls");
dis.search();
break;
case 2:
system("cls");
dis.display();
break;
case 6:
exit(0);
break;
default:
exit(0);
}
cout<<"If you want to go to the main menu press 3: ";
cin>>choice;
if (choice == 3)
{
system("cls");
return main();
}
}
|