Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Users.h"
- #include "Functions.h"
- // ----------------------Class Person----------------//
- Person::Person() { username = "admin"; password = "admin"; }
- string Person::getusername() { return username; }
- string Person::getpassword() { return password; }
- void Person::setusername(string a) { username = a; }
- void Person::setpassword(string a) { password = a; }
- // Student Class Functions
- void Person::addStudent() {}
- void Person::editStudent() {}
- string Person::DeleteStudent(string a) { return "Hassan"; }
- void Person::updateStudent() {}
- void Person::saveStudent() {}
- void Person::searchStudent() {}
- void Person::CheckStudentSave() {}
- void Person::DisplayRecord() {}
- void Person::Set_Student_Id(string a) {}
- void Person::Set_Student_College_Id(string a) {}
- void Person::Set_Student_Name(string a) {}
- void Person::Set_Student_Mobile(string a) {}
- void Person::Set_Student_Email(string a) {}
- void Person::Set_Student_Username(string a) {}
- void Person::Set_Student_Password(string a) {}
- void Person::Set_Student_Address(string a) {}
- string Person::getstudentid() { return "Hassan"; }
- string Person::getstudentname() { return "Hassan"; }
- string Person::getstudentcollegeid() { return "Hassan"; }
- // ----------------------Class Admin----------------//
- Admin::Admin() {}
- // ----------------------Class User----------------//
- User::User() {}
- // ----------------------Class Librarian----------------//
- Librarian::Librarian() {}
- // ----------------------Student Class----------------//
- Student::Student() {}
- void Student::addStudent()
- {
- cout << "Enter Student ID: ";
- getline(cin, student_id);
- cout << "Enter Student College ID: ";
- getline(cin, student_college_id);
- cout << "Enter Student Name: ";
- getline(cin, student_name);
- cout << "Enter Student Mobile: ";
- getline(cin, student_mobile);
- cout << "Enter Student Email: ";
- getline(cin, student_email);
- string temp;
- cout << "Enter Student Username: ";
- getline(cin, temp);
- this->Set_Student_Username(temp);
- cout << "Enter Student Password: ";
- getline(cin, temp);
- this->Set_Student_Password(temp);
- cout << "Enter Student Address: ";
- getline(cin, student_address);
- saveStudent();
- }
- void Student::editStudent()
- {
- cout << "Enter Student ID: ";
- getline(cin, student_id);
- cout << "Enter Student College ID: ";
- getline(cin, student_college_id);
- cout << "Enter Student Name: ";
- getline(cin, student_name);
- cout << "Enter Student Mobile: ";
- getline(cin, student_mobile);
- cout << "Enter Student Email: ";
- getline(cin, student_email);
- cout << "Enter Student Username: ";
- string temp;
- getline(cin, temp);
- this->Set_Student_Username(temp);
- cout << "Enter Student Password: ";
- getline(cin, temp);
- this->Set_Student_Password(temp);
- cout << "Enter Student Address: ";
- getline(cin, student_address);
- cout << "\n\nSuccess! Student Information Edited!\n";
- CheckStudentSave();
- }
- void Student::updateStudent()
- {
- cout << "What would you like to Update?" << endl
- << "1) Student ID \n"
- << "2) Student College ID \n"
- << "3) Student Name \n"
- << "4) Student Mobile \n"
- << "5) Student Email\n"
- << "6) Student Username \n"
- << "7) Student Password \n"
- << "8) Student Address \n"
- << "Pick your Number: ";
- int ch;
- bool fh = true;
- cin >> ch;
- cin.ignore();
- cout << "Enter Updated Value: ";
- string temp;
- switch (ch)
- {
- case 1:
- getline(cin, student_id);
- break;
- case 2:
- getline(cin, student_college_id);
- break;
- case 3:
- getline(cin, student_name);
- break;
- case 4:
- getline(cin, student_mobile);
- break;
- case 5:
- getline(cin, student_email);
- break;
- case 6:
- getline(cin, temp);
- this->Set_Student_Username(temp);
- break;
- case 7:
- getline(cin, temp);
- this->Set_Student_Password(temp);
- break;
- case 8:
- getline(cin, student_address);
- break;
- default:
- cout << "Invalid Choice Entered.\n";
- fh = false;
- break;
- }
- if (fh)
- {
- cout << "Success! Data has been updated\n";
- CheckStudentSave();
- }
- else
- {
- cout << "Press Enter to Continue.\n";
- (void)getchar();
- }
- }
- void Student::CheckStudentSave()
- {
- cout << "Would you like to save this updated data? Press y for yes, n for no: ";
- char check;
- cin >> check;
- cin.ignore();
- switch (check)
- {
- case 'y':
- case 'Y':
- SaveStudentUpdate();
- break;
- default:
- cout << "Press Enter to Continue...\n";
- (void)getchar();
- break;
- }
- }
- void Student::DisplayRecord()
- {
- cout << endl;
- cout << "Student ID: " << student_id << endl
- << "Student College ID: " << student_college_id << endl
- << "Student Name: " << student_name << endl
- << "Student Mobile: " << student_mobile << endl
- << "Student Email: " << student_email << endl
- << "Student Username: " << getusername() << endl
- //Password not shown.
- << "Student Address " << student_address << endl;
- }
- void Student::saveStudent()
- {
- ofstream WriteStudent;
- try
- {
- WriteStudent.open("Student Data.FILE", ios::out | ios::app);
- WriteStudent << student_id << "\n";
- WriteStudent << student_college_id << "\n";
- WriteStudent << student_name << "\n";
- WriteStudent << student_mobile << "\n";
- WriteStudent << student_email << "\n";
- string temp;
- temp = getusername();
- WriteStudent << temp << "\n";
- temp = getpassword();
- WriteStudent << temp << "\n";
- WriteStudent << student_address << "\n";
- WriteStudent.close();
- cout << "Success! Data has been Updated!\n";
- }
- catch (exception X)
- {
- cout << "File Failed to load. \n";
- }
- cout << "Press Enter to Continue...";
- (void)getchar();
- }
- void Student::Set_Student_Id(string a) { student_id = a; }
- void Student::Set_Student_College_Id(string a) { student_college_id = a; }
- void Student::Set_Student_Name(string a) { student_name = a; }
- void Student::Set_Student_Mobile(string a) { student_mobile = a; }
- void Student::Set_Student_Email(string a) { student_email = a; }
- void Student::Set_Student_Username(string a) { this->setusername(a); }
- void Student::Set_Student_Password(string a) { this->setpassword(a); }
- void Student::Set_Student_Address(string a) { student_address = a; }
- string Student::DeleteStudent(string id)
- {
- if (id == this->student_id)
- return id;
- return "None";
- }
- string Student::getstudentid() { return student_id; }
- string Student::getstudentname() { return student_name; }
- string Student::getstudentcollegeid() { return student_college_id; }
- void Student::searchStudent() {}
Add Comment
Please, Sign In to add comment