Advertisement
Guest User

Untitled

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