Guest User

Untitled

a guest
May 10th, 2019
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.36 KB | None | 0 0
  1. #include "Users.h"
  2. #include "Functions.h"
  3. // ----------------------Class Person----------------//
  4. Person::Person() { username = "admin"; password = "admin"; }
  5. string Person::getusername() { return username; }
  6. string Person::getpassword() { return password; }
  7. void Person::setusername(string a) { username = a; }
  8. void Person::setpassword(string a) { password = a; }
  9.  
  10. // Student Class Functions
  11. void Person::addStudent() {}
  12. void Person::editStudent() {}
  13. string Person::DeleteStudent(string a) { return "Hassan"; }
  14. void Person::updateStudent() {}
  15. void Person::saveStudent() {}
  16. void Person::searchStudent() {}
  17. void Person::CheckStudentSave() {}
  18. void Person::DisplayRecord() {}
  19. void Person::Set_Student_Id(string a) {}
  20. void Person::Set_Student_College_Id(string a) {}
  21. void Person::Set_Student_Name(string a) {}
  22. void Person::Set_Student_Mobile(string a) {}
  23. void Person::Set_Student_Email(string a) {}
  24. void Person::Set_Student_Username(string a) {}
  25. void Person::Set_Student_Password(string a) {}
  26. void Person::Set_Student_Address(string a) {}
  27. string Person::getstudentid() { return "Hassan"; }
  28. string Person::getstudentname() { return "Hassan"; }
  29. string Person::getstudentcollegeid() { return "Hassan"; }
  30. // ----------------------Class Admin----------------//
  31. Admin::Admin() {}
  32. // ----------------------Class User----------------//
  33. User::User() {}
  34.  
  35. // ----------------------Class Librarian----------------//
  36. Librarian::Librarian() {}
  37.  
  38. // ----------------------Student Class----------------//
  39. Student::Student() {}
  40. void Student::addStudent()
  41. {
  42.  
  43. cout << "Enter Student ID: ";
  44. getline(cin, student_id);
  45. cout << "Enter Student College ID: ";
  46. getline(cin, student_college_id);
  47. cout << "Enter Student Name: ";
  48. getline(cin, student_name);
  49. cout << "Enter Student Mobile: ";
  50. getline(cin, student_mobile);
  51. cout << "Enter Student Email: ";
  52. getline(cin, student_email);
  53. string temp;
  54. cout << "Enter Student Username: ";
  55. getline(cin, temp);
  56. this->Set_Student_Username(temp);
  57. cout << "Enter Student Password: ";
  58. getline(cin, temp);
  59. this->Set_Student_Password(temp);
  60. cout << "Enter Student Address: ";
  61. getline(cin, student_address);
  62. saveStudent();
  63. }
  64. void Student::editStudent()
  65. {
  66. cout << "Enter Student ID: ";
  67. getline(cin, student_id);
  68. cout << "Enter Student College ID: ";
  69. getline(cin, student_college_id);
  70. cout << "Enter Student Name: ";
  71. getline(cin, student_name);
  72. cout << "Enter Student Mobile: ";
  73. getline(cin, student_mobile);
  74. cout << "Enter Student Email: ";
  75. getline(cin, student_email);
  76. cout << "Enter Student Username: ";
  77. string temp;
  78. getline(cin, temp);
  79. this->Set_Student_Username(temp);
  80. cout << "Enter Student Password: ";
  81. getline(cin, temp);
  82. this->Set_Student_Password(temp);
  83. cout << "Enter Student Address: ";
  84. getline(cin, student_address);
  85.  
  86. cout << "\n\nSuccess! Student Information Edited!\n";
  87. CheckStudentSave();
  88. }
  89. void Student::updateStudent()
  90. {
  91. cout << "What would you like to Update?" << endl
  92. << "1) Student ID \n"
  93. << "2) Student College ID \n"
  94. << "3) Student Name \n"
  95. << "4) Student Mobile \n"
  96. << "5) Student Email\n"
  97. << "6) Student Username \n"
  98. << "7) Student Password \n"
  99. << "8) Student Address \n"
  100. << "Pick your Number: ";
  101. int ch;
  102. bool fh = true;
  103. cin >> ch;
  104. cin.ignore();
  105. cout << "Enter Updated Value: ";
  106. string temp;
  107. switch (ch)
  108. {
  109. case 1:
  110. getline(cin, student_id);
  111. break;
  112. case 2:
  113. getline(cin, student_college_id);
  114. break;
  115. case 3:
  116. getline(cin, student_name);
  117. break;
  118. case 4:
  119. getline(cin, student_mobile);
  120. break;
  121. case 5:
  122. getline(cin, student_email);
  123. break;
  124. case 6:
  125. getline(cin, temp);
  126. this->Set_Student_Username(temp);
  127. break;
  128. case 7:
  129. getline(cin, temp);
  130. this->Set_Student_Password(temp);
  131. break;
  132. case 8:
  133. getline(cin, student_address);
  134. break;
  135. default:
  136. cout << "Invalid Choice Entered.\n";
  137. fh = false;
  138. break;
  139. }
  140. if (fh)
  141. {
  142. cout << "Success! Data has been updated\n";
  143. CheckStudentSave();
  144. }
  145. else
  146. {
  147. cout << "Press Enter to Continue.\n";
  148. (void)getchar();
  149. }
  150. }
  151. void Student::CheckStudentSave()
  152. {
  153. cout << "Would you like to save this updated data? Press y for yes, n for no: ";
  154. char check;
  155. cin >> check;
  156. cin.ignore();
  157. switch (check)
  158. {
  159. case 'y':
  160. case 'Y':
  161. SaveStudentUpdate();
  162. break;
  163. default:
  164. cout << "Press Enter to Continue...\n";
  165. (void)getchar();
  166. break;
  167. }
  168. }
  169. void Student::DisplayRecord()
  170. {
  171. cout << endl;
  172. cout << "Student ID: " << student_id << endl
  173. << "Student College ID: " << student_college_id << endl
  174. << "Student Name: " << student_name << endl
  175. << "Student Mobile: " << student_mobile << endl
  176. << "Student Email: " << student_email << endl
  177. << "Student Username: " << getusername() << endl
  178. //Password not shown.
  179. << "Student Address " << student_address << endl;
  180. }
  181. void Student::saveStudent()
  182. {
  183. ofstream WriteStudent;
  184. try
  185. {
  186. WriteStudent.open("Student Data.FILE", ios::out | ios::app);
  187. WriteStudent << student_id << "\n";
  188. WriteStudent << student_college_id << "\n";
  189. WriteStudent << student_name << "\n";
  190. WriteStudent << student_mobile << "\n";
  191. WriteStudent << student_email << "\n";
  192. string temp;
  193. temp = getusername();
  194. WriteStudent << temp << "\n";
  195. temp = getpassword();
  196. WriteStudent << temp << "\n";
  197. WriteStudent << student_address << "\n";
  198. WriteStudent.close();
  199. cout << "Success! Data has been Updated!\n";
  200. }
  201. catch (exception X)
  202. {
  203. cout << "File Failed to load. \n";
  204. }
  205. cout << "Press Enter to Continue...";
  206. (void)getchar();
  207. }
  208. void Student::Set_Student_Id(string a) { student_id = a; }
  209. void Student::Set_Student_College_Id(string a) { student_college_id = a; }
  210. void Student::Set_Student_Name(string a) { student_name = a; }
  211. void Student::Set_Student_Mobile(string a) { student_mobile = a; }
  212. void Student::Set_Student_Email(string a) { student_email = a; }
  213. void Student::Set_Student_Username(string a) { this->setusername(a); }
  214. void Student::Set_Student_Password(string a) { this->setpassword(a); }
  215. void Student::Set_Student_Address(string a) { student_address = a; }
  216. string Student::DeleteStudent(string id)
  217. {
  218. if (id == this->student_id)
  219. return id;
  220. return "None";
  221. }
  222. string Student::getstudentid() { return student_id; }
  223. string Student::getstudentname() { return student_name; }
  224. string Student::getstudentcollegeid() { return student_college_id; }
  225. void Student::searchStudent() {}
Add Comment
Please, Sign In to add comment