diff --git a/README.md b/README.md index e674b94..136a171 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,82 @@ # Buffer_2.0 Buffer_2.0 repo to submit your projects to.Repository containing folder-wise code for all submissions to Buffer : A Project Series, conducted between April, 2021 - June, 2020. -Each folder should contain a separate README to describe the files and project objective + BUS RESERVATION SYSTEM + +TEAM MEMBERS:- +1. SIDDHI NALAWADE - SY (E&TC) +2. GAURI PATIL - SY(E&TC) +3. MRUNAL NILGILWAR - SY(E&TC) +1)OBJECTIVE OF THE PROJECT:- + +The objective and scope of my Project Bus Reservation System is to record the details various activities of user. +It will simplifies the task and reduse the paper work. +This system will greatly simplfy and speed up the reservation of seats in bus. +The system is very user friendly and it is anticipated that functions of the system will be easily accessed by administrators, academics, students and applicants. +FEATURES:- + + 1) Works for both administrator and user. + + 2) Sign up, login, Forgotten password functions. + + 3) Add bus details. + + 4) Booking and Reservation of seats. + + 5) Searching , Updating and Cancellation of seats . + + 6)View bus details , Route details , Seat reservation details . + + 7)Renew function helps to renewing the bus and seat details at the end of the day. + +2)DATA STRUCTURES USED and WHY? :- + +1.ARRAYS: + + -In an array, accessing an element is very easy by using the index number. + + -The search process can be applied to an array easily. + + -For any reason a user wishes to store multiple values of similar type then the Array can be used and + utilized efficiently. + + -Arrays have constant search times or Big O of one (O(1)), which is very fast. Fundamentally, the best + possible run time complexity is O(1). +2.File: + + -Backup: It is possible to take faster and automatic back-up of database stored in files of computer-based + systems. Computer systems provide functionalities to serve this purpose.it is also possible to develop + specific application program for this purpose. + + -Compactness: It is possible to store data compactly. + + -Data Retrieval: Computer-based systems provide enhanced data retrieval techniques to retrieve data stored + in files in easy and efficient way. + + -Editing: It is easy to edit any information stored in computers in form of files. Specific application + programs or editing software can be used for this purpose. + + -Sharing: Data stored in files of computer-based systems ca be shared among multiple users at a same time. + +3)WHAT DID WE LEARN FROM THIS PROJECT:- + +-File handling. + +-Some new functions such as sleep(), system("cls"), etc. + +-Time and space complexity. + +-Organising various functions in proper manner. + +-Choosing efficient data structures. + +4)WHAT NEXT FOR THE PROJECT:- + +-Modify this project by using trees and graphs as trees will help user to find the nearest seat possible, + to find window seat etc. + +-We will modify it by adding gender information so that it will be easy for user to choose a seat according + to their comfort. + +-Build a front end for proper visualization and to make it user friendly. diff --git a/bus_reservation.cpp b/bus_reservation.cpp new file mode 100644 index 0000000..41547da --- /dev/null +++ b/bus_reservation.cpp @@ -0,0 +1,1019 @@ +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; +class bus +{ +private: +string b_no,b_name,d_name; +int b_seats; +public: +void controll(); +void admin(); +void user_menu(); +void user_login(); +void signup(); +void login(); +void forget(); +void user_options(); +void new_bus(); +void view_bus(); +void view_single_bus(); +void view_all_bus(); +void update_bus(); +void route_bus(); +void seat_detail_bus(); +void booking(); +void renew_bus(); +void search_booking(); +void update_booking(); +void del_booking(); + + +}; + +void bus::controll() +{ +system("cls"); +p: +int option; +cout<<"\n********************************************************************************************"; +cout<<"\n\t\t Welcome to Gold Bus Agency!"; +cout<<"\n********************************************************************************************"; +cout<<"\n\n\t 1. Administration mode"; +cout<<"\n\n\t 2. User mode"; +cout<<"\n\n\t 3. Exit"; +cout<<"\n\n\t Enter your choice :"; +cin>>option; +switch(option) +{ +case 1: +admin(); +break; +case 2: + user_menu(); + break; +case 3: +cout<<"\n\nYou have been successfully logged out. Thank you for visiting!"; +exit(0); +default: +cout<<"\n\n Invalid choice...Please try again..."; +} +getch(); +goto p; +} + + +void bus::admin() +{ +bus b; +p: +system("cls"); +string email,pass; +char ch; +int opt; +cout<<"\n\n\t\t\t************Login*************"; +cout<<"\n\nEmail :"; +cin>>email; +cout<<"\n\nPassword :"; +for(int i=1;i<6;i++) +{ +ch= getch(); +pass += ch; +cout<<"*"; +} +if(email=="siddhi@gmail.com" && pass=="sid12") +{ +cout<<"\n\n\n\t\t\tLoading..."; +for(int i=1;i<=5;i++) +{ +Sleep(500); +cout<<"."; +} +z: +system("cls"); +cout<<"\n1. Add bus detail :"; +cout<<"\n2. Update bus details :"; +cout<<"\n3. Renew seats"; +cout<<"\n4. Go back :"; +cout<<"\nEnter your choice :"; +cin>>opt; +switch(opt) +{ +case 1: +new_bus(); + break; +case 2: +update_bus(); + break; + case 3: + renew_bus(); + break; +case 4: +controll(); + default: +cout<<"\n\n Invalid choice...Please try again..."; +} +getch(); +goto z; +} +else +{ +cout<<"\n\n\t\tYour email and password is wrong..."; +getch(); +goto p; +} +} + +void bus::user_menu() +{ +system("cls"); +int choice; +cout<<"\n********************************************************************************************"; +cout<<"\n\t\t Welcome to Gold Bus Agency!"; +cout<<"\n********************************************************************************************"; +cout<<"\n\n\t 1. Sign up "; +cout<<"\n\n\t 2. Login"; +cout<<"\n\n\t 3. Forgotten Password "; +cout<<"\n\n\t 4. Go back"; + +cout<<"\n\n\t Enter your choice :"; +cin>>choice; +switch(choice) +{ +case 1: +signup(); +break; +case 2: +login(); +break; +case 3: +forget(); +break; +case 4: +controll(); +break; +default: + system("cls"); + cout<<"\n\n\t Something got wrong , Try again \n"; + +} +} + +void bus::signup() +{ +system("cls"); +fstream log; +string user,pass; +cout<<"\n\n\t Enter the username : "; +cin>>user; +cout<<"\n\n\t Enter the password : "; +cin>>pass; + +log.open("login.txt",ios::app|ios::out); +log<>user; +cout<<"\n\n\t Enter the PASSWORD : "; +cin>>pass; +ifstream input("login.txt"); +while(input>>us>>pa){ +if(us == user && pa == pass){ +i =1; + +} +} +input.close(); +if(i==1) +{ +cout<<"\n\n\t Hello"<>cho; +switch(cho){ +case 1:{ + + +string searchuse,su,sp; +int j=0; +cout<<"Enter your remembered USERNAME : "; +cin>>searchuse; +ifstream search("login.txt"); +while(search>>su>>sp){ +if(su==searchuse){ +j=1; + +} + + + + +}search.close(); +if(j==1){ +cout<<"\n\t CONGRATULATIONS You have successfully restored your account"; +cout<<" \n\t Your Password is "<>choice; +switch(choice) +{ +case 1: + view_bus(); +break; +case 2: + route_bus(); +break; +case 3: + seat_detail_bus(); +break; +case 4: + booking(); +break; +case 5: + search_booking(); +break; +case 6: +update_booking(); +break; +case 7: +del_booking(); +break; +case 8: +controll(); +default: +cout<<"\n\n Invalid choice...Please try again..."; +} +getch(); +goto p; +} + +void bus::new_bus() +{ +p: +system("cls"); +fstream file; +string t_no,tb_name,td_name; +int t_seats,found=0; +cout<<"\n\t\t____________________GOLD BUS AGENCY_____________________"; +cout<<"\n\n Bus no:"; +cin>>b_no; +cout<<"\n\n Bus name :"; +cin>>b_name; +cout<<"\n\n Total seats :"; +cin>>b_seats; +cout<<"\n\n Driver name :"; +cin>>d_name; +file.open("bus.txt",ios::in); +if(!file) +{ +file.open("bus.txt",ios::app|ios::out); +file<>t_no>>tb_name>>t_seats>>td_name; +while(!file.eof()) +{ +if(b_no==t_no) +{ +found++; +} +file>>t_no>>tb_name>>t_seats>>td_name; +} +file.close(); +if(found==0) +{ + file.open("bus.txt",ios::app|ios::out); + file<>option; +switch(option) +{ +case 1: +view_single_bus(); +break; +case 2: +view_all_bus(); +break; +case 3: +user_menu(); +default: +cout<<"\n\n Invalid choice...Please try again..."; + +} +getch(); +goto g; + +} + +void bus::view_single_bus() +{ +system("cls"); +string t_no; +fstream file; +int found=0; +cout<<"\n\t\t____________________GOLD BUS AGENCY_____________________"; +cout<<"\n\n SINGLE BUS INFORMATION"; +cout<<"\n\n Bus no :"; +cin>>t_no; +file.open("bus.txt",ios::in); +if(!file) +{ +cout<<"\n\n File openning error."; +} +else +{ + file>>b_no>>b_name>>b_seats>>d_name; + while(!file.eof()) + { + if(t_no == b_no) + { + system("cls"); + cout<<"\n\t\t____________________GOLD BUS AGENCY_____________________"; + cout<<"\n\n SINGLE BUS INFORMATION"; + cout<<"\n BUS NO \t\tBUS NAME \tNO. OF SEATS \tDRIVER NAME"; + cout<<"\n "<>b_no>>b_name>>b_seats>>d_name; + } + file.close(); + if(found==0) + { + cout<<"\n\n Invalid bus no"; + } +} +} + +void bus::view_all_bus() +{ +system("cls"); +fstream file; +cout<<"\n\t\t____________________GOLD BUS AGENCY_____________________"; +cout<<"\n\n ALL BUS INFORMATION"; +file.open("bus.txt",ios::in); +if(!file) +{ +cout<<"\n\n File openning error."; +} +else +{ +system("cls"); +cout<<"\n\t\t____________________GOLD BUS AGENCY_____________________"; +cout<<"\n\n ALL BUS INFORMATION"; + cout<<"\n\nBUS NO \t\tBUS NAME \tNO. OF SEATS \tDRIVER NAME"; + file>>b_no>>b_name>>b_seats>>d_name; + while(!file.eof()) + { + + + + cout<<"\n "<>b_no>>b_name>>b_seats>>d_name; + } + file.close(); +} + +} + +void bus::update_bus() +{ +system("cls"); +fstream file,file1; +string t_no,no,t_name,td_name; +int t_seats,found=0; +cout<<"\n\t\t____________________GOLD BUS AGENCY_____________________"; +cout<<"\n\nUPDATE BUS INFORMATION"; +file.open("bus.txt",ios::in); +if(!file) +{ +cout<<"\n\n File openning error "; +} +else +{ +cout<<"\n\n Bus no:"; +cin>>t_no; +file1.open("bus1.txt",ios::app|ios::out); +file>>b_no>>b_name>>b_seats>>d_name; +while(!file.eof()) +{ +if(t_no == b_no) +{ +cout<<"\n\n New Bus no :"; +cin>>no; +cout<<"\n\n Bus name :"; +cin>>t_name; +cout<<"\n\n No. of seats :"; +cin>>t_seats; +cout<<"\n\n Driver name :"; +cin>>td_name; +file1<>b_no>>b_name>>b_seats>>d_name; +} +file.close(); +file1.close(); +remove("bus.txt"); +rename("bus1.txt","bus.txt"); +if(found==0) +{ +cout<<"\n\n Bus no. is invalid"; +} +} + +} + +void bus::route_bus() +{ +system("cls"); +p: +int choice; +cout<<"\n\t\t____________________GOLD BUS AGENCY_____________________"; +cout<<"\n\n 1. 1st bus route details"; +cout<<"\n 2. 2nd route bus details"; +cout<<"\n 3. 3rd bus route details"; +cout<<"\n 4. 4th bus route details"; +cout<<"\n 5. 5th bus route details"; +cout<<"\n 6. Go back"; +cout<<"\n\n Enter your choice"; + cin>>choice; + switch(choice) + { + case 1: + cout<<"\n From Pune to Mumbai"; + cout<<"\n9:00 am......................10:00 am"; + cout<<"\n From Swargate to Lonavla"; + cout<<"\n9:00 am......................11:00 am"; + cout<<"\n From Lonavala to Mumbai"; + cout<<"\n11:00 am.....................1:00 pm"; + break; + case 2: + cout<<"\n From Pune to Nashik"; + cout<<"\n9:00 am......................10:00 am"; + cout<<"\n From Swargate to Nagar"; + cout<<"\n9:00 am......................11:00 am"; + cout<<"\n From Nagar to Nashik"; + cout<<"\n11:00 am.....................1:00 pm"; + break; + case 3: + cout<<"\n From Pune to Dhule"; + cout<<"\n9:00 am......................10:00 am"; + cout<<"\n From Swargate to Nashik"; + cout<<"\n9:00 am......................11:00 am"; + cout<<"\n From Nashik to Dhule"; + cout<<"\n11:00 am.....................1:00 pm"; + break; + case 4: + cout<<"\n From Pune to Kolhapur"; + cout<<"\n9:00 am......................10:00 am"; + cout<<"\n From Swargate to Satara"; + cout<<"\n9:00 am......................11:00 am"; + cout<<"\n From Satara to Kolhapur"; + cout<<"\n11:00 am.....................1:00 pm"; + break; + case 5: + cout<<"\n From Pune to Dapoli"; + cout<<"\n9:00 am......................10:00 am"; + cout<<"\n From Swargate to Lonavala"; + cout<<"\n9:00 am......................11:00 am"; + cout<<"\n From Lonavala to Dapoli"; + cout<<"\n11:00 am.....................1:00 pm"; + break; + case 6: + user_menu(); + default: + cout<<"\n\n Invalid choice...Please try again..."; +} +getch(); +goto p; +} +void bus::seat_detail_bus() +{ +system("cls"); +fstream file,file1; +string t_no,s_b_no,s_no; +int count=0,found=0; +cout<<"\n\t\t____________________GOLD BUS AGENCY_____________________"; +cout<<"\n SEAT DETAILS"; +file.open("bus.txt",ios::in); +file1.open("seat.txt",ios::in); + +if(!file || !file1) +{ +cout<<"\n\n File openning error"; +} +else +{ +cout<<"\n\n Bus no :"; +cin>>t_no; +file1>>s_b_no>>s_no; +while(!file1.eof()) +{ +if(t_no == s_b_no) +{ +count++; +} +file1>>s_b_no>>s_no; +} +file1.close(); +file>>b_no>>b_name>>b_seats>>d_name; +while(!file.eof()) +{ +if(t_no == b_no) +{ +cout<<"\n\n Total no. of seats :"<>b_no>>b_name>>b_seats>>d_name; +} +file.close(); +if(found == 0) +{ +cout<<"\n\n Bus no. Invalid."; +} +} + +} + +void bus::booking() +{ +p: +system("cls"); +fstream file; +string t_no,s_b_no,customer_name,phone,from,to; +int found =0,s_no,seats,count=0,s_s_no,ss_no[25],i=0,s_amount,total_amount=0,r_amount; +char x; +cout<<"\n\t\t____________________GOLD BUS AGENCY_____________________"; +cout<<"\n SEAT RESERVATION"; +file.open("bus.txt",ios::in); +if(!file) +{ +cout<<"\n\n File openning error"; +} +else +{ +cout<<"\n\n Bus no :"; +cin>>t_no; +file.close(); +file.open("seat.txt",ios::in); +if(file) +{ +file>>s_b_no>>s_s_no; +while(!file.eof()) +{ +if(t_no == s_b_no) +{ +count++; +} +file>>s_b_no>>s_s_no; +} +file.close(); + } +file.open("bus.txt",ios::in); +file>>b_no>>b_name>>b_seats>>d_name; +while(!file.eof()) +{ +if(t_no == b_no) +{ +seats = b_seats; +found++; +} +file>>b_no>>b_name>>b_seats>>d_name; +} +file.close(); +if(seats-count == 0) +{ +cout<<"\n\n All Seats of this bus is already reserved"; +} +else if(found == 1) +{ +do{ +h: +cout<<"\n\n Seat no :"; +cin>>s_no; +if(s_no > seats) +{ +cout<<"\n\n Seat No. is invalid. Please try again"; +goto h; +} +file.open("seat.txt",ios::in); +if(!file) +{ + file.open("seat.txt",ios::app|ios::out); + file<>s_b_no>>s_s_no; +while(!file.eof()) +{ +if(t_no == s_b_no && s_no == s_s_no) +{ +cout<<"\n\n Seat is already reserved plaese try again"; +goto h; +} +file>>s_b_no>>s_s_no; +} +file.close(); +file.open("seat.txt",ios::app|ios::out); + file<>x; +}while(x == 'Y' || x == 'y' ); +system("cls"); +cout<<"\n\t\t____________________GOLD BUS AGENCY_____________________"; +cout<<"\n\n Customer name :"; +cin>>customer_name; +cout<<"\n\n Phone number :"; +cin>>phone; +cout<<"\n\n From :"; +cin>>from; +cout<<"\n\n To :"; +cin>>to; +cout<<"\n\n Single amount :"; +cin>>s_amount; +total_amount = s_amount*i; +cout<<"\n\n Total amount : "<>r_amount; +file.open("customer.txt",ios::app|ios::in); +file<>x; +if(x == 'Y' || x == 'y') +{ +remove("seat.txt"); +cout<<"\n\n\t\t All seats rreservation renewed."; +} +else +{ +cout<<"\n\n\t\t All seats reservation is saved."; +} +} +} + +void bus::update_booking() +{ +system("cls"); +fstream file,file1; +int t_seats,t_amo,found=0,del_seats,i=0; +string name,no,phone,t_phone,del_no; +cout<<"\n\t\t____________________GOLD BUS AGENCY_____________________"; +cout<<"\n UPDATE YOUR BOOKING"; +file.open("customer.txt",ios::in); +if(!file) +{ +cout<<"\n\n File openning error"; +} +else +{ +cout<<"\n\nEnter your phone number : "; +cin>>t_phone; +file>>name>>no>>phone>>t_seats>>t_amo; +while(!file.eof()) +{ +if(t_phone == phone) +{ + file.close(); + file.open("customer.txt",ios::in); + file1.open("customer1.txt",ios::app|ios::out); + file>>name>>no>>phone>>t_seats>>t_amo; + while(!file.eof()) + { + if(t_phone == phone) + { + del_no = no; + del_seats = t_seats; +} + if(t_phone != phone) + { + file<>name>>no>>phone>>t_seats>>t_amo; +} +file.close(); +file1.close(); +remove("customer.txt"); +rename("customer1.txt","customer.txt"); +file.open("seat.txt",ios::in); +file1.open("seat1.txt",ios::app|ios::out); +file>>no>>t_seats; +while(!file.eof()) +{ +if(!(del_no == no && i < del_seats)) +{ +file1<>no>>t_seats; +} +file.close(); +file1.close(); +remove("seat.txt"); +rename("seat1.txt","seat.txt"); +booking(); +cout<<"\n\nUpdated your record successfully."; +found++; + goto h; +} +file>>name>>no>>phone>>t_seats>>t_amo; +} +file.close(); +h: +if(found == 0) +{ +cout<<"\n\n Phone number is invalid"; +} +} +} + +void bus::del_booking() +{ +system("cls"); +fstream file,file1; +int t_seats,t_amo,found=0,del_seats,i=0; +string name,no,phone,t_phone,del_no; +cout<<"\n\t\t____________________GOLD BUS AGENCY_____________________"; +cout<<"\n CANCELLATION OF TICKET"; +file.open("customer.txt",ios::in); +if(!file) +{ +cout<<"\n\n File openning error"; +} +else +{ +cout<<"\n\nEnter your phone number : "; +cin>>t_phone; +file>>name>>no>>phone>>t_seats>>t_amo; +while(!file.eof()) +{ +if(t_phone == phone) +{ + file.close(); + file.open("customer.txt",ios::in); + file1.open("customer1.txt",ios::app|ios::out); + file>>name>>no>>phone>>t_seats>>t_amo; + while(!file.eof()) + { + if(t_phone == phone) + { + del_no = no; + del_seats = t_seats; +} + if(t_phone != phone) + { + file<>name>>no>>phone>>t_seats>>t_amo; +} +file.close(); +file1.close(); +remove("customer.txt"); +rename("customer1.txt","customer.txt"); +file.open("seat.txt",ios::in); +file1.open("seat1.txt",ios::app|ios::out); +file>>no>>t_seats; +while(!file.eof()) +{ +if(!(del_no == no && i < del_seats)) +{ +file1<>no>>t_seats; +} +file.close(); +file1.close(); +remove("seat.txt"); +rename("seat1.txt","seat.txt"); +cout<<"\n\nDeleted booking record successfully"; +found++; + goto h; +} +file>>name>>no>>phone>>t_seats>>t_amo; +} +file.close(); +h: +if(found == 0) +{ +cout<<"\n\n Phone number is invalid"; +} +} +} + +void bus::search_booking() +{ +system("cls"); +fstream file; +string name,no,phone,t_name; +int t_seats,t_amo,found=0; +cout<<"\n\t\t____________________GOLD BUS AGENCY_____________________"; +cout<<"\n CUSTOMER TICKET DETAILS"; +file.open("customer.txt",ios::in); +if(!file) +{ +cout<<"\n\n File oprnning error"; + } + else + { + cout<<"\n\n Customer Name :"; + cin>>t_name; + file>>name>>no>>phone>>t_seats>>t_amo; + while(!file.eof()) + { + if(t_name == name) + { + if(found == 0) + { + system("cls"); + cout<<"\n\t\t____________________GOLD BUS AGENCY_____________________"; + cout<<"\n CUSTOMER TICKET DETAILS"; + } + cout<<"\n\n\n Customer name :"<>name>>no>>phone>>t_seats>>t_amo; +} +file.close(); +if(found == 0) +{ +cout<<"\n\n Customer name is Invalid."; +} +} + +} + + +main() +{ +bus b; +b.controll(); +} +