Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <conio.h>
- using namespace std;
- class NewTravelTrip
- {
- public:
- NewTravelTrip();
- NewTravelTrip(int m)
- { }
- void AddTrip();
- string name;
- string date;
- string address;
- string phoneno;
- int invoice;
- string email;
- vector<string>tripdate;
- void EditTrip();
- void DeleteTrip();
- //string date;
- vector<string>startlocation;
- vector<string>finaldestination;
- };
- vector<NewTravelTrip>trips;
- int inv;
- class ShowAllUser
- {
- public:
- void showUser();
- int invoice;
- string name;
- string date;
- string address;
- string phoneno;
- string email;
- string tripdate;
- string triplocation;
- void DeleteUser();
- void EditUser();
- };
- NewTravelTrip::NewTravelTrip()
- {
- string t_date, s_loc, f_des;
- invoice = inv;
- cout << "\n\tInvoice ID: " << invoice ;
- getline(cin,date);
- cout << "\n\tEnter Date: " ;
- getline(cin,date);
- cout << "\tEnter User Name: " ;
- getline(cin, name);
- cout << "\tEnter User Address: " ;
- getline(cin, address);
- cout << "\tEnter User Phone No.: " ;
- cin >> phoneno;
- cout << "\tEnter User Email Address: " ;
- cin >> email;
- cout << "\tEnter Trip Date: " ;
- cin >> t_date;
- cout << "\tEnter Trip Location: \n" ;
- getline(cin, s_loc);
- cout <<"\t\tStart Location : ";
- getline(cin, s_loc);
- cout <<"\t\tFinal Location : ";
- getline(cin, f_des);
- tripdate.push_back(t_date);
- startlocation.push_back(s_loc);
- finaldestination.push_back(f_des);
- inv++;
- }
- void NewTravelTrip::AddTrip()
- {
- int in_id, i, j;
- cout<<"\n\tEnter Invoice ID : ";
- cin>>in_id;
- for(i = 0; i < trips.size(); i++)
- {
- if(trips[i].invoice == in_id)
- j = i;
- }
- string t_date, s_loc, f_des;
- cout << "\tEnter Trip Date: " ;
- cin >> t_date;
- cout << "\tEnter Trip Location: \n" ;
- getline(cin, s_loc);
- cout <<"\t\tStart Location : ";
- getline(cin, s_loc);
- cout <<"\t\tFinal Location : ";
- getline(cin, f_des);
- trips[j].tripdate.push_back(t_date);
- trips[j].startlocation.push_back(s_loc);
- trips[j].finaldestination.push_back(f_des);
- }
- void NewTravelTrip::EditTrip()
- {
- int in_id, i, j, x, y, z;
- cout<<"\n\tEnter Invoice ID : ";
- cin>>in_id;
- for(i = 0; i < trips.size(); i++)
- {
- if(trips[i].invoice == in_id)
- j = i;
- }
- for(x = 0; x < trips[j].tripdate.size(); x++)
- {
- cout<<"\tDo you want to edit this trip? Enter 'Y' for yes, 'N' for no."<<endl;
- cout << "\tTrip Date: " <<trips[j].tripdate[x]<<endl;
- cout << "\tTrip Location: "<<endl;
- cout <<"\t\tStart Location : "<<trips[j].startlocation[x]<<endl;
- cout <<"\t\tFinal Location : "<<trips[j].finaldestination[x]<<endl<<endl;
- string inp;
- cin>>inp;
- if(inp == "Y")
- {
- string t_date, s_loc, f_des;
- cout << "\n\tEnter Trip Date: " ;
- cin >> t_date;
- cout << "\tEnter Trip Location: \n" ;
- getline(cin, s_loc);
- cout <<"\t\tStart Location : ";
- getline(cin, s_loc);
- cout <<"\t\tFinal Location : ";
- getline(cin, f_des);
- trips[j].tripdate[x] = t_date;
- trips[j].startlocation[x] = s_loc;
- trips[j].finaldestination[x] = f_des;
- break;
- }
- }
- }
- void NewTravelTrip::DeleteTrip()
- {
- int in_id, i, j, x, y, z;
- cout<<"\n\tEnter Invoice ID : ";
- cin>>in_id;
- for(i = 0; i < trips.size(); i++)
- {
- if(trips[i].invoice == in_id)
- j = i;
- }
- for(x = 0; x < trips[j].tripdate.size(); x++)
- {
- cout<<"\tDo you want to delete this trip? Enter 'Y' for yes, 'N' for no."<<endl;
- cout << "\tTrip Date: " <<trips[j].tripdate[x]<<endl;
- cout << "\tTrip Location: "<<endl;
- cout <<"\t\tStart Location : "<<trips[j].startlocation[x]<<endl;
- cout <<"\t\tFinal Location : "<<trips[j].finaldestination[x]<<endl<<endl;
- string inp;
- cin>>inp;
- if(inp == "Y")
- {
- vector<string>::iterator it;
- it = trips[j].tripdate.begin();
- for(y = 0; y < x; y++)
- it++;
- trips[j].tripdate.erase(it);
- it = trips[j].startlocation.begin();
- for(y = 0; y < x; y++)
- it++;
- trips[j].startlocation.erase(it);
- it = trips[j].finaldestination.begin();
- for(y = 0; y < x; y++)
- it++;
- trips[j].finaldestination.erase(it);
- break;
- }
- }
- }
- void ShowAllUser::showUser()
- {
- int sz, i, j;
- sz = trips.size();
- for(i = 0; i < sz; i++)
- {
- cout << "\n\tInvoice ID: " << trips[i].invoice<<endl ;
- cout << "\tDate: " <<trips[i].date<<endl;
- cout << "\tUser Name: " <<trips[i].name<<endl;
- cout << "\tUser Address: " <<trips[i].address<<endl;
- cout << "\tUser Phone No.: " <<trips[i].phoneno<<endl;
- cout << "\tUser Email Address: " <<trips[i].email<<endl;
- for(j = 0; j < trips[i].tripdate.size(); j++)
- {
- cout << "\tTrip Date: " <<trips[i].tripdate[j]<<endl;
- cout << "\tTrip Location: "<<endl;
- cout <<"\t\tStart Location : "<<trips[i].startlocation[j]<<endl;
- cout <<"\t\tFinal Location : "<<trips[i].finaldestination[j]<<endl<<endl;
- }
- cout<<endl<<endl;
- }
- }
- void ShowAllUser::EditUser()
- {
- int in_id, i, j, x, y, z;
- string t_date, s_loc, f_des;
- cout<<"\n\tEnter Invoice ID : ";
- cin>>in_id;
- for(i = 0; i < trips.size(); i++)
- {
- if(trips[i].invoice == in_id)
- j = i;
- }
- getline(cin, trips[j].date);
- cout << "\tEnter New Date: " ;
- getline(cin, trips[j].date);
- cout << "\tEnter New User Name: " ;
- getline(cin, trips[j].name);
- cout << "\tEnter New User Address: " ;
- getline(cin, trips[j].address);
- cout << "\tEnter New User Phone No.: " ;
- cin >> trips[j].phoneno;
- cout << "\tEnter User New Email Address: " ;
- cin >> trips[j].email;
- trips[j].tripdate.clear();
- trips[j].finaldestination.clear();
- trips[j].startlocation.clear();
- getline(cin, t_date);
- cout << "\tEnter New Trip Date: " ;
- getline(cin, t_date);
- cout << "\tEnter New Trip Location: \n" ;
- cout <<"\t\tStart New Location : ";
- getline(cin, s_loc);
- cout <<"\t\tFinal New Location : ";
- getline(cin, f_des);
- trips[j].tripdate.push_back(t_date);
- trips[j].startlocation.push_back(s_loc);
- trips[j].finaldestination.push_back(f_des);
- }
- void ShowAllUser::DeleteUser()
- {
- int in_id, i, j, x, y, z;
- string t_date, s_loc, f_des;
- cout<<"Enter Invoice ID : ";
- cin>>in_id;
- for(i = 0; i < trips.size(); i++)
- {
- if(trips[i].invoice == in_id)
- j = i;
- }
- vector<NewTravelTrip>::iterator it;
- it = trips.begin();
- for(i = 0; i < j; i++)
- it++;
- trips.erase(it);
- }
- int main()
- {
- int choice;
- inv = 1;
- while(1)
- {
- cout <<"Please, Choose Your Option: "<<endl;
- cout <<endl;
- cout<<" 1. New Travel Trip. "<<endl;
- cout<<" 2. Show All Users. "<<endl;
- cout<<" 3. Edit User. "<<endl;
- cout<<" 4. Delete User. "<<endl;
- cout<<" 5. Add Trip. "<<endl;
- cout<<" 6. Edit Trip. "<<endl;
- cout<<" 7. Delete Trip. "<<endl;
- cout<<endl;
- cout<<" Enter Your Choice: ";
- cin>>choice;
- if(choice == 1)
- {
- cout <<"\nYou have chosen New Travel Trip"<<endl;
- NewTravelTrip ad;
- trips.push_back(ad);
- cout <<"\nPress any key to go to the main menu";
- getch();
- cout<<endl<<endl;
- }
- if(choice == 2)
- {
- cout <<"\nYou have chosen Show All Users"<<endl;
- ShowAllUser show;
- show.showUser();
- cout <<"\nPress any key to go to the main menu";
- getch();
- cout<<endl<<endl;
- }
- if(choice == 3)
- {
- cout <<"\nYou have chosen Edit User"<<endl;
- ShowAllUser ed;
- ed.EditUser();
- cout <<"\nPress any key to go to the main menu";
- getch();
- cout<<endl<<endl;
- }
- if(choice == 4)
- {
- cout <<"\nYou have chosen Delete User"<<endl;
- ShowAllUser ed;
- ed.DeleteUser();
- cout <<"\nPress any key to go to the main menu";
- getch();
- cout<<endl<<endl;
- }
- if(choice == 5)
- {
- cout <<"\nYou have chosen Add Trip"<<endl;
- NewTravelTrip tp(0);
- tp.AddTrip();
- cout <<"\nPress any key to go to the main menu";
- getch();
- cout<<endl<<endl;
- }
- if(choice == 6)
- {
- cout <<"\nYou have chosen Edit Trip"<<endl;
- NewTravelTrip tp(0);
- tp.EditTrip();
- cout <<"\nPress any key to go to the main menu";
- getch();
- cout<<endl<<endl;
- }
- if(choice == 7)
- {
- cout <<"\nYou have chosen Delete Trip"<<endl;
- NewTravelTrip tp(0);
- tp.DeleteTrip();
- cout <<"\nPress any key to go to the main menu";
- getch();
- cout<<endl<<endl;
- }
- else
- {
- cout<<"\nWrong Input!Going back to Main Menu.\n\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement