Advertisement
Guest User

project

a guest
Jul 2nd, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdio>
  4. #include <conio.h>
  5. #include <cstdlib>
  6. #include <stdio.h>
  7. #include <istream>
  8. using namespace std;
  9. class Customer
  10. {
  11. public:
  12. string str_NIC ;
  13. /* public:
  14. Customer(){}
  15. Customer(string name, string NIC, string City, string ContactNumber, string Username, string Password) ;
  16. //void Login();
  17. //void SearchFile_and_Update() ;
  18. //void Deletes() ;
  19. ~Customer() ;*/
  20. };
  21. // class Seats
  22. class Seats{
  23. private:
  24. int i_SeatNo ;
  25. public:
  26. void CheckSeatAvailabilty() ;
  27. };
  28. // class Reservations
  29. class Reservations : public Customer,public Seats{
  30. protected :
  31. string str_Arrival_St, str_Dep_St ;
  32. int i_No_Tickets, i_Charge ;
  33. double i_total ;
  34. public:
  35. Reservations();
  36. // to make a reservation
  37. Reservations(string NIC, string EndTime, string StartTime, int NoTickets );
  38. void Show(string, string, string, int, int);
  39. ~Reservations();
  40. };
  41. // Reservations constructor
  42. inline Reservations :: Reservations(string NIC, string EndTime, string StartTime, int NoTickets ){
  43.  
  44. Reservations r2 ;
  45. str_NIC = NIC ;
  46. str_Dep_St = EndTime ;
  47. str_Arrival_St = StartTime ;
  48. i_No_Tickets = NoTickets ;
  49. int tot=i_No_Tickets*600 ;
  50. cout <<"Total Price for Tickets is Rs:"<<"\t"<<tot ;
  51. /* ifstream PaymentsRead ;
  52. PaymentsRead.open("Payments.txt") ;
  53. double ch ;
  54. string s1,s2 ;
  55. while(PaymentsRead >> s1 >> s2 >> ch){
  56. if((str_Dep_St == s1) & (str_Arrival_St == s2)){
  57. i_total = CalculateFee(ch, i_No_Tickets);
  58. }*/
  59.  
  60. char confirmation ;
  61. cout << "\n\nConfirm the Reservation(Y/N): \n\n" ;
  62. cin >> confirmation ;
  63. confirmation = tolower(confirmation);
  64. if(confirmation == 'y'){
  65. fstream Reservations ;
  66. fstream Seats ;
  67. string line ;
  68. Reservations.open("Reservations.txt", ios::app | ios:: out | ios::ate);
  69. Seats.open("Seat.txt", ios :: app | ios :: out | ios :: ate | ios :: in);
  70. Seats << str_NIC << "\t" << i_No_Tickets <<"\n" ;
  71. Reservations << str_NIC <<"\t"<< str_Dep_St <<"\t"<< str_Arrival_St <<"\t"<< i_No_Tickets
  72. << "\t" << tot <<"\n";
  73. Reservations.close();
  74. }
  75. else{
  76. cout << "\n\nConfirmation denied and exiting from the program \n" ;
  77. exit(0) ;
  78. }
  79. r2.Show(str_NIC, str_Dep_St, str_Arrival_St, i_No_Tickets, tot ) ;
  80. }
  81. // Reservations - Show
  82. inline void Reservations :: Show(string NIC, string Dept_St, string Arrival_St, int No_Tickets, int tot ){
  83. system("CLS") ;
  84. cout <<"\n\nNIC :" << NIC << "\n"
  85. <<"\n\nDep. St. :" << Dept_St << "\t\t"
  86. <<"Arrival St. :" << Arrival_St <<"\n\n"
  87. <<"No_Tickets :" << No_Tickets <<"\t"
  88. <<"Charge for one ticket :" << "600" <<"\t"
  89. << "total = " << tot <<"\n\n" ;
  90. }
  91. // Reservations Deconstructor
  92. inline Reservations :: ~Reservations(){}
  93.  
  94. // Seats - CheckSeatAvailability
  95. inline void Seats :: CheckSeatAvailabilty(){
  96. int number_of_lines = 0 ;
  97. // string line ;
  98. //ifstream SeatAvailbility ;
  99. //SeatAvailbility.open("Seats.txt");
  100. //int number_of_lines = 0;
  101. //int number_of_lines = 0, track=1;
  102. string line;
  103. ifstream myfile("Seats.txt");
  104. while (myfile.good ())
  105. {
  106. getline(myfile, line);
  107. //cout << line << endl;
  108. if (line=="")
  109. {
  110. cout << "Number of lines for track " << " is "<<number_of_lines<< endl;
  111. number_of_lines=0;
  112. // track++;
  113. }
  114. else
  115. {
  116. ++number_of_lines;
  117. }
  118.  
  119. }
  120. cout << "Number of lines for track " << " is "<<number_of_lines<< endl;
  121. //system("pause");
  122. myfile.close();
  123. } // seat availability function end
  124. // Customer constructor
  125. // inline Customer :: Customer(string name, string NIC, string City, string ContactNumber, /*string Username, string Password*/){
  126. /* str_name = name ;
  127. str_NIC = NIC ;
  128. str_City = City ;
  129. str_ContactNumber = ContactNumber ;
  130. //str_UserName = Username ;
  131. //str_Password = Password ;
  132. fstream registration ;
  133. registration.open("Customer.txt", ios::app | ios:: out | ios::ate);
  134. registration << str_NIC <<"\t"<< str_name <<"\t"<< str_City <<"\t"<< str_ContactNumber <<"\t"<< str_UserName
  135. <<"\t" << str_Password << "\n";
  136. registration.close();
  137. }*/
  138. // Reservations constructor
  139. inline Reservations :: Reservations(){}
  140. int main()
  141. {
  142. string name, NIC, City, Password, UserName, ContactNumber, StartTime, EndTime;
  143. int subChoice2,nt ;
  144. cout << "-------------------------------------------------\n\n"
  145. << "\n\n1.Make a Reservation\n\n"
  146. /*<< "2.Modify Reservation\n\n"
  147. << "3.Cancel Reservation\n\n"
  148. << "\n\nEnter your choice :"*/ ;
  149. cin >> subChoice2 ;
  150. switch(subChoice2){
  151. case 1:{
  152. system("CLS");
  153. Reservations R2 ;
  154. // R2.Login() ;
  155. char check ;
  156. system("CLS");
  157. cout << "\n\nCheck seat availabilty(Y/N) ?\n" ;
  158. cin >> check ;
  159. check = tolower(check);
  160. if(check == 'y'){
  161. // TimeTables T1 ;
  162. // Payments P1 ;
  163. R2.CheckSeatAvailabilty();
  164. //T1.Show();
  165. // P1.Show();
  166. cout << "\n\n Customer NIC:\n\n " ;
  167. cin >> NIC ;
  168. cout << "\n\n Start Time\n\n " ;
  169. cin >> StartTime ;
  170. cout << "\n\n End Time\n\n " ;
  171. cin >> EndTime ;
  172. cout << "\n\nNo. of Tickets\n\n " ;
  173. cin >> nt ;
  174. Reservations R2(NIC,StartTime, EndTime, nt);
  175. }
  176. }; break;
  177. }
  178. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement