0% found this document useful (0 votes)
18 views3 pages

Oops (LMS)

Uploaded by

advi.2003.ap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

Oops (LMS)

Uploaded by

advi.2003.ap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include <iostream>

#include <vector>
#include <string>

using namespace std;

class User {
protected:
string name;
string userID;
public:
User(string name, string userID) : name(name), userID(userID) {}
virtual void viewDetails() const = 0; // pure virtual function
virtual ~User() {}
};
class Admin : public User {
private:
static int studentCount;
static int facultyCount;
vector<string> coursesOffered;

public:
Admin(string name, string userID) : User(name, userID) {}

static void addStudent() {


studentCount++;
cout << "Student added. Total students: " << studentCount << endl;
}

static void addFaculty() {


facultyCount++;
cout << "Faculty added. Total faculty: " << facultyCount << endl;
}

void addCourse(const string& course) {


coursesOffered.push_back(course);
cout << "Course " << course << " added successfully!" << endl;
}

void viewDetails() const override {


cout << "Admin Name: " << name << ", ID: " << userID << endl;
}
};

int Admin::studentCount = 0;
int Admin::facultyCount = 0;
class Faculty : public User {
private:
vector<string> courseMaterials;
vector<string> classSchedule;
vector<pair<string, char>> grades; // StudentID and Grade
public:
Faculty(string name, string userID) : User(name, userID) {}

void updateGrade(const string& studentID, char grade) {


grades.push_back(make_pair(studentID, grade));
cout << "Grade updated for Student ID: " << studentID << endl;
}
void addCourseMaterial(const string& material) {
courseMaterials.push_back(material);
cout << "Material added: " << material << endl;
}

void addClassSchedule(const string& schedule) {


classSchedule.push_back(schedule);
cout << "Class schedule added: " << schedule << endl;
}

void viewDetails() const override {


cout << "Faculty Name: " << name << ", ID: " << userID << endl;
}

void viewGrades() const {


for (const auto& grade : grades) {
cout << "Student ID: " << grade.first << ", Grade: " << grade.second <<
endl;
}
}
};
class Student : public User {
private:
vector<string> registeredCourses;
vector<pair<string, char>> grades;
double financialStatus;
public:
Student(string name, string userID, double financialStatus = 0.0)
: User(name, userID), financialStatus(financialStatus) {}

void registerCourse(const string& course) {


registeredCourses.push_back(course);
cout << "Course registered: " << course << endl;
}

void viewGrades() const {


for (const auto& grade : grades) {
cout << "Course: " << grade.first << ", Grade: " << grade.second <<
endl;
}
}

void makePayment(double amount) {


financialStatus -= amount;
cout << "Payment made. Current balance: $" << financialStatus << endl;
}

void viewFinancialStatus() const {


cout << "Financial Status: $" << financialStatus << endl;
}

void viewDetails() const override {


cout << "Student Name: " << name << ", ID: " << userID << endl;
}

void addGrade(const string& course, char grade) {


grades.push_back(make_pair(course, grade));
}
};
class Course {
private:
string courseID;
string courseName;
public:
Course(string id, string name) : courseID(id), courseName(name) {}

const string& getCourseID() const {


return courseID;
}

const string& getCourseName() const {


return courseName;
}

void displayCourse() const {


cout << "Course ID: " << courseID << ", Name: " << courseName << endl;
}
};
int main() {
Admin admin1("Alice", "A1001");
Faculty faculty1("Dr. Smith", "F2001");
Student student1("John", "S3001", 1000.0);

admin1.addStudent();
admin1.addFaculty();
admin1.addCourse("CS101");

faculty1.addCourseMaterial("Lecture 1: Introduction to Programming");


faculty1.addClassSchedule("Mon/Wed 10-11 AM");
//faculty1.updateGrade(student1.userID, 'A');

student1.registerCourse("CS101");
student1.viewGrades();
student1.makePayment(500);
student1.viewFinancialStatus();

return 0;
}

You might also like