Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstdio>
- #include <conio.h>
- #include <cstdlib>
- #include <stdio.h>
- #include <istream>
- using namespace std;
- class Customer
- {
- public:
- string str_NIC ;
- /* public:
- Customer(){}
- Customer(string name, string NIC, string City, string ContactNumber, string Username, string Password) ;
- //void Login();
- //void SearchFile_and_Update() ;
- //void Deletes() ;
- ~Customer() ;*/
- };
- // class Seats
- class Seats{
- private:
- int i_SeatNo ;
- public:
- void CheckSeatAvailabilty() ;
- };
- // class Reservations
- class Reservations : public Customer,public Seats{
- protected :
- string str_Arrival_St, str_Dep_St ;
- int i_No_Tickets, i_Charge ;
- double i_total ;
- public:
- Reservations();
- // to make a reservation
- Reservations(string NIC, string EndTime, string StartTime, int NoTickets );
- void Show(string, string, string, int, int);
- ~Reservations();
- };
- // Reservations constructor
- inline Reservations :: Reservations(string NIC, string EndTime, string StartTime, int NoTickets ){
- Reservations r2 ;
- str_NIC = NIC ;
- str_Dep_St = EndTime ;
- str_Arrival_St = StartTime ;
- i_No_Tickets = NoTickets ;
- int tot=i_No_Tickets*600 ;
- cout <<"Total Price for Tickets is Rs:"<<"\t"<<tot ;
- /* ifstream PaymentsRead ;
- PaymentsRead.open("Payments.txt") ;
- double ch ;
- string s1,s2 ;
- while(PaymentsRead >> s1 >> s2 >> ch){
- if((str_Dep_St == s1) & (str_Arrival_St == s2)){
- i_total = CalculateFee(ch, i_No_Tickets);
- }*/
- char confirmation ;
- cout << "\n\nConfirm the Reservation(Y/N): \n\n" ;
- cin >> confirmation ;
- confirmation = tolower(confirmation);
- if(confirmation == 'y'){
- fstream Reservations ;
- fstream Seats ;
- string line ;
- Reservations.open("Reservations.txt", ios::app | ios:: out | ios::ate);
- Seats.open("Seat.txt", ios :: app | ios :: out | ios :: ate | ios :: in);
- Seats << str_NIC << "\t" << i_No_Tickets <<"\n" ;
- Reservations << str_NIC <<"\t"<< str_Dep_St <<"\t"<< str_Arrival_St <<"\t"<< i_No_Tickets
- << "\t" << tot <<"\n";
- Reservations.close();
- }
- else{
- cout << "\n\nConfirmation denied and exiting from the program \n" ;
- exit(0) ;
- }
- r2.Show(str_NIC, str_Dep_St, str_Arrival_St, i_No_Tickets, tot ) ;
- }
- // Reservations - Show
- inline void Reservations :: Show(string NIC, string Dept_St, string Arrival_St, int No_Tickets, int tot ){
- system("CLS") ;
- cout <<"\n\nNIC :" << NIC << "\n"
- <<"\n\nDep. St. :" << Dept_St << "\t\t"
- <<"Arrival St. :" << Arrival_St <<"\n\n"
- <<"No_Tickets :" << No_Tickets <<"\t"
- <<"Charge for one ticket :" << "600" <<"\t"
- << "total = " << tot <<"\n\n" ;
- }
- // Reservations Deconstructor
- inline Reservations :: ~Reservations(){}
- // Seats - CheckSeatAvailability
- inline void Seats :: CheckSeatAvailabilty(){
- int number_of_lines = 0 ;
- // string line ;
- //ifstream SeatAvailbility ;
- //SeatAvailbility.open("Seats.txt");
- //int number_of_lines = 0;
- //int number_of_lines = 0, track=1;
- string line;
- ifstream myfile("Seats.txt");
- while (myfile.good ())
- {
- getline(myfile, line);
- //cout << line << endl;
- if (line=="")
- {
- cout << "Number of lines for track " << " is "<<number_of_lines<< endl;
- number_of_lines=0;
- // track++;
- }
- else
- {
- ++number_of_lines;
- }
- }
- cout << "Number of lines for track " << " is "<<number_of_lines<< endl;
- //system("pause");
- myfile.close();
- } // seat availability function end
- // Customer constructor
- // inline Customer :: Customer(string name, string NIC, string City, string ContactNumber, /*string Username, string Password*/){
- /* str_name = name ;
- str_NIC = NIC ;
- str_City = City ;
- str_ContactNumber = ContactNumber ;
- //str_UserName = Username ;
- //str_Password = Password ;
- fstream registration ;
- registration.open("Customer.txt", ios::app | ios:: out | ios::ate);
- registration << str_NIC <<"\t"<< str_name <<"\t"<< str_City <<"\t"<< str_ContactNumber <<"\t"<< str_UserName
- <<"\t" << str_Password << "\n";
- registration.close();
- }*/
- // Reservations constructor
- inline Reservations :: Reservations(){}
- int main()
- {
- string name, NIC, City, Password, UserName, ContactNumber, StartTime, EndTime;
- int subChoice2,nt ;
- cout << "-------------------------------------------------\n\n"
- << "\n\n1.Make a Reservation\n\n"
- /*<< "2.Modify Reservation\n\n"
- << "3.Cancel Reservation\n\n"
- << "\n\nEnter your choice :"*/ ;
- cin >> subChoice2 ;
- switch(subChoice2){
- case 1:{
- system("CLS");
- Reservations R2 ;
- // R2.Login() ;
- char check ;
- system("CLS");
- cout << "\n\nCheck seat availabilty(Y/N) ?\n" ;
- cin >> check ;
- check = tolower(check);
- if(check == 'y'){
- // TimeTables T1 ;
- // Payments P1 ;
- R2.CheckSeatAvailabilty();
- //T1.Show();
- // P1.Show();
- cout << "\n\n Customer NIC:\n\n " ;
- cin >> NIC ;
- cout << "\n\n Start Time\n\n " ;
- cin >> StartTime ;
- cout << "\n\n End Time\n\n " ;
- cin >> EndTime ;
- cout << "\n\nNo. of Tickets\n\n " ;
- cin >> nt ;
- Reservations R2(NIC,StartTime, EndTime, nt);
- }
- }; break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement