#include <iostream>
#include <string>
using namespace std;
class Student;
class Course;
// Department Class
class Department {
public:
int deptID;
string deptName;
void display() {
cout << "Dept ID: " << deptID << ", Name: " << deptName << endl;
}
};
// Course Class
class Course {
public:
int courseID;
string courseName;
Teacher* teacher;
Department* dept;
Student* students[10];
int studentCount;
Course() {
studentCount = 0;
teacher = NULL;
dept = NULL;
}
void display() {
cout << "Course ID: " << courseID << ", Name: " << courseName << endl;
if (dept != NULL)
cout << "Department: " << dept->deptName << endl;
if (teacher != NULL)
cout << "Assigned Teacher: " << teacher->name << endl;
}
void addStudent(Student* student) {
if (studentCount < 10) {
students[studentCount++] = student;
} else {
cout << "Course is full.\n";
}
}
};
// Student Class
class Student {
public:
int studentID;
string name;
Department* dept;
Course* courses[10];
float grades[10];
int courseCount;
Student() {
courseCount = 0;
dept = NULL;
}
void display() {
cout << "Student ID: " << studentID << ", Name: " << name << endl;
if (dept != NULL)
cout << "Enrolled in Department: " << dept->deptName << endl;
for (int i = 0; i < courseCount; i++) {
cout << "Enrolled in Course: " << courses[i]->courseName << endl;
}
}
void viewGrades() {
cout << "Grades for student " << name << ":\n";
for (int i = 0; i < courseCount; i++) {
cout << "Course: " << courses[i]->courseName << ", Grade: " << grades[i] << endl;
}
}
void enrollInCourse(Course* course) {
if (courseCount < 10) {
courses[courseCount] = course;
grades[courseCount] = 0;
course->addStudent(this);
courseCount++;
cout << "Student " << name << " enrolled in " << course->courseName << endl;
} else {
cout << "Maximum courses reached.\n";
}
}
};
// Teacher Class
class Teacher {
public:
int teacherID;
string name;
Department* dept;
Course* course;
Teacher() {
dept = NULL;
course = NULL;
}
void display() {
cout << "Teacher ID: " << teacherID << ", Name: " << name << endl;
if (dept != NULL)
cout << "Assigned Department: " << dept->deptName << endl;
if (course != NULL)
cout << "Assigned Course: " << course->courseName << endl;
}
void assignGrades(Student& student, Course& course, float grade) {
for (int i = 0; i < [Link]; i++) {
if ([Link][i]->courseID == [Link]) {
[Link][i] = grade;
cout << "Grade assigned to student " << [Link] << " for course " <<
[Link] << ": " << grade << endl;
return;
}
}
cout << "Student not enrolled in this course.\n";
}
void viewStudentsInCourse() {
if (course == NULL) {
cout << "No course assigned.\n";
return;
}
cout << "Students enrolled in " << course->courseName << ":\n";
for (int i = 0; i < course->studentCount; i++) {
cout << course->students[i]->name << endl;
}
}
};
// Enrollment Class
class Enrollment {
public:
Student* student;
Course* course;
void input() {
cout << "Enter Student ID: ";
int studentID;
cin >> studentID;
cout << "Enter Course ID: ";
int courseID;
cin >> courseID;
}
void display() {
cout << "Student enrolled in course.\n";
}
};
// Result Class
class Result {
public:
float calculateResult(Student& student) {
float totalMarks = 0;
for (int i = 0; i < [Link]; i++) {
totalMarks += [Link][i];
}
if ([Link] == 0)
return 0;
return totalMarks / [Link];
}
};
// Librarian Class
class Librarian {
public:
int bookID;
string bookTitle;
bool isAvailable;
void addBook() {
cout << "Enter Book ID: ";
cin >> bookID;
cout << "Enter Book Title: ";
[Link]();
getline(cin, bookTitle);
isAvailable = true;
}
void display() {
cout << "Book ID: " << bookID << ", Title: " << bookTitle << ", Available: " << (isAvailable ?
"Yes" : "No") << endl;
}
void borrowBook(int studentID, string studentName) {
if (isAvailable) {
isAvailable = false;
cout << "Student ID: " << studentID << ", Name: " << studentName << " borrowed the
book: " << bookTitle << endl;
} else {
cout << "Book is not available." << endl;
}
}
void returnBook(int studentID, string studentName) {
isAvailable = true;
cout << "Student ID: " << studentID << ", Name: " << studentName << " returned the book:
" << bookTitle << endl;
}
};
// University Class
class University {
public:
string universityName;
Department departments[10];
Teacher teachers[10];
Student students[10];
Course courses[10];
Enrollment enrollments[10];
Librarian library[10];
int deptCount, teacherCount, studentCount, courseCount, enrollmentCount, bookCount;
University() {
deptCount = teacherCount = studentCount = courseCount = enrollmentCount = bookCount
= 0;
}
void inputUniversity() {
cout << "Enter University Name: ";
[Link]();
getline(cin, universityName);
}
void addDepartment(int deptID, string deptName) {
departments[deptCount].deptID = deptID;
departments[deptCount].deptName = deptName;
deptCount++;
}
void addTeacher(int teacherID, string teacherName, Department* dept, Course* course) {
teachers[teacherCount].teacherID = teacherID;
teachers[teacherCount].name = teacherName;
teachers[teacherCount].dept = dept;
teachers[teacherCount].course = course;
teacherCount++;
}
void addCourse(int courseID, string courseName, Teacher* teacher, Department* dept) {
courses[courseCount].courseID = courseID;
courses[courseCount].courseName = courseName;
courses[courseCount].teacher = teacher;
courses[courseCount].dept = dept;
courseCount++;
}
void addStudent(int studentID, string studentName, Department* dept) {
students[studentCount].studentID = studentID;
students[studentCount].name = studentName;
students[studentCount].dept = dept;
studentCount++;
}
void addEnrollment(Student* student, Course* course) {
if (enrollmentCount < 10) {
enrollments[enrollmentCount].student = student;
enrollments[enrollmentCount].course = course;
enrollmentCount++;
student->enrollInCourse(course);
}
}
void displayDepartments() {
cout << "\nDepartments:\n";
for (int i = 0; i < deptCount; i++) {
departments[i].display();
}
}
void displayTeachers() {
cout << "\nTeachers:\n";
for (int i = 0; i < teacherCount; i++) {
teachers[i].display();
}
}
void displayStudents() {
cout << "\nStudents:\n";
for (int i = 0; i < studentCount; i++) {
students[i].display();
}
}
void displayCourses() {
cout << "\nCourses:\n";
for (int i = 0; i < courseCount; i++) {
courses[i].display();
}
}
void displayLibrary() {
cout << "\nLibrary Books:\n";
for (int i = 0; i < bookCount; i++) {
library[i].display();
}
}
};