Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <windows.h>
  5. using namespace std;
  6.  
  7. const int Size=20;
  8.  
  9. class Manager
  10. {
  11. //Private Start
  12.  
  13. private:
  14.  
  15.  
  16. struct AppointmentData //Structured Array Start
  17. {
  18. string StudentName;
  19. string ID;
  20. string PhoneContact;
  21. string Appointment_Time;
  22. } Appointment[Size]; //Structured Array End
  23.  
  24. //Private End
  25.  
  26.  
  27.  
  28. //Public Start
  29.  
  30. public:
  31.  
  32. AppointmentType(); //Constructor
  33.  
  34.  
  35. void SetAppointment( string& , string&, string&, string&);
  36.  
  37.  
  38. void printAppointment()const;//Access
  39. string GetInformation()const;
  40. string GetInformation1()const;
  41. string GetInformation2()const;
  42. string GetInformation3()const;
  43.  
  44.  
  45.  
  46.  
  47. //Public End
  48.  
  49. };
  50.  
  51. int main()
  52. {
  53. //Object
  54. Manager Appointments;
  55.  
  56. ifstream readFile;
  57.  
  58. ofstream WriteFile;
  59.  
  60. string Stu, ID, PC, App_Time;
  61.  
  62. char Operator=' ';
  63.  
  64. do
  65. {
  66. cout<<"\n-------------------------";
  67. cout<<"\n (1)Add a New Appointment:"
  68. <<"\n (2)Update/Edit an Appointment:"
  69. <<"\n (3)Display All Appointments:"
  70. <<"\n (4)Search for an Appointment(by ID#):"
  71. <<"\n (5)Delete an Appointment :"
  72. <<"\n (6)Help Guide :"
  73. <<"\n (x)Exit program Press:"
  74. <<"\n-------------------------\n Enter Your Choice:";
  75. cin>>Operator;
  76.  
  77. switch (Operator)
  78. {
  79. case '1':
  80.  
  81. for(int i =0; i < Size ; i++)
  82. {
  83.  
  84.  
  85. WriteFile.open("Appointments2.txt",ios::app|ios::out);
  86.  
  87. cout <<"\n Enter Name: ";
  88. cin.get();
  89. getline(cin, Stu);
  90.  
  91. cout<<"\n Enter ID: ";
  92. getline(cin, ID);
  93.  
  94. cout<<"\n Enter Phone Contact: ";
  95. getline(cin, PC);
  96.  
  97. cout<<"\n Enter Appointment Time: ";
  98. getline(cin, App_Time);
  99.  
  100. Appointments.SetAppointment(Stu,ID,PC,App_Time);
  101.  
  102. WriteFile<<Stu<<endl<<ID<<endl<<PC<<endl<<App_Time;
  103.  
  104. break;
  105. }
  106. break;
  107.  
  108. case '3':
  109.  
  110.  
  111. Appointments.printAppointment();
  112.  
  113.  
  114. break;
  115.  
  116.  
  117. case 'x':
  118. cout << "\n The program has been exited";
  119.  
  120. break;
  121. }
  122. }
  123. while(Operator!='x');
  124. WriteFile.close();
  125. }
  126.  
  127. //Constructor Start
  128. Manager::AppointmentType() // Constructor
  129.  
  130. {
  131. for(int i=0; i<Size; i++)
  132. {
  133.  
  134. Appointment[i].StudentName="";
  135. Appointment[i].ID="";
  136. Appointment[i].PhoneContact="";
  137. Appointment[i].Appointment_Time="";
  138. }
  139. }
  140. //Constructor End
  141.  
  142.  
  143.  
  144. // Mutator Start
  145. void Manager::SetAppointment(string& Stu,string& ID,string& PC,string& App_Time) //SetAppointments Start
  146. {
  147. ifstream readFile;
  148.  
  149. readFile.open("Appointments2.txt",ios::in);
  150.  
  151. for(int i = 0; i< Size; i++)
  152. {
  153. readFile>>Stu>>ID>>PC>>App_Time;
  154.  
  155. for (int i =0; i <Size; i++)
  156. {
  157. if(Appointment[i].StudentName == "")
  158. {
  159. Appointment[i].StudentName=Stu;
  160. Appointment[i].ID =ID;
  161. Appointment[i].PhoneContact =PC;
  162. Appointment[i].Appointment_Time=App_Time;
  163. break;
  164. }
  165.  
  166. }
  167.  
  168. } //Set Appointments End
  169. readFile.close();
  170. }
  171.  
  172.  
  173.  
  174. //MutatorEnd
  175.  
  176.  
  177.  
  178.  
  179. void Manager::printAppointment()const //Print Info Start
  180. {
  181. for (int i =0; i <Size; i++)
  182. {
  183. if(Appointment[i].StudentName!="")
  184. {
  185. cout<<"\n Student Name: "<<Appointment[i].StudentName
  186. <<"\n Student ID: "<<Appointment[i].ID
  187. <<"\n Student PhoneContact:"<<Appointment[i].PhoneContact
  188. <<"\n Student AppointmentTime#: "<<Appointment[i].Appointment_Time<<endl<<endl;
  189. }
  190.  
  191. }
  192.  
  193. } //Print Info End
  194.  
  195.  
  196. //Access End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement