School Management System Project Report
School Management System Project Report
1. Introduction
The School Management System (SMS) is designed to automate and simplify the management
of students, teachers, administrative staff, and courses in an educational institution. The project
has Java's Object-Oriented Programming (OOP) concepts such as inheritance, polymorphism,
interfaces, and file handling to provide a seamless experience for managing various operations
like course enrollment, report generation, and data persistence.
This report outlines the features, design, and implementation of the School Management System,
developed by a team for the Semester Project.
2. Project Overview
The School Management System will manage the following components:
Students: Students can enroll in courses, view their enrolled courses, and maintain their
personal details.
Teachers: Teachers are assigned courses to teach, and they can view the courses they
teach.
Administrative Staff: Staff can generate reports, add or remove students, teachers, and
courses, and manage the overall operations of the system.
Courses: Courses can have students enrolled, teachers assigned, and grades tracked.
The system integrates a Graphical User Interface (GUI) for managing students, teachers, and
courses, allowing users to perform CRUD (Create, Read, Update, Delete) operations.
3. Functions
Core Functionalities
1. User Roles
o Student:
Attributes: studentID, name, address, dateOfBirth, list of enrolled courses.
Methods:
enrollInCourse(Course course): Adds a course to the student's list
of enrolled courses.
displayCourses(): Lists all the courses the student is enrolled in.
Page | 1
o Teacher:
Attributes: teacherID, name, specialization, list of courses taught.
Methods:
assignCourse(Course course): Adds a course to the teacher's list of
courses.
displayCourses(): Lists all the courses taught by the teacher.
o Administrative Staff:
Attributes: staffID, name, role, and department.
Methods:
generateReport(List<Person> people): Generates reports for
students, teachers, or courses.
2. Course Management:
o Attributes: courseID, title, credits, assignedTeacher, list of enrolled students.
o Methods:
addStudent(Student student): Adds a student to the course.
removeStudent(Student student): Removes a student from the course.
calculateAverageGrade(): Calculates the average grade of all students in
the course.
3. Inheritance:
o Base class Person containing common attributes (name, email, dateOfBirth).
o Student, Teacher, and AdministrativeStaff classes inherit from Person.
4. Polymorphism and Dynamic Binding:
o Overridden methods such as generateReport() in AdministrativeStaff and
displayDetails() in Student and Teacher.
5. Static Data Members and Methods:
o Static counters to track the total number of students, teachers, and courses In
University class.
o Static method displaySystemStats() to show system statistics.
6. Interfaces:
Page | 2
o Interface Reportable with methods generateReport() and exportToFile(),
implemented by AdministrativeStaff and Teacher.
7. Composition:
o A Course object references a Teacher object and an array of Student objects.
8. Object Arrays and ArrayList:
o Use of object arrays to store Student and Course objects.
o Use of ArrayList for dynamic management of students enrolled in courses.
9. File Handling:
o Methods to load and save data to files: loadData(String filename) and
saveData(String filename) using buffer and input output stream
10. Generics:
o Generic class Repository<T> for managing lists of Student, Teacher, and Course.
11. Wrapper Classes:
o Use of wrapper classes for numeric data processing, such as calculating the
average and median grades in courses.
12. Static & Dynamic Typing:
o Demonstrating static typing with explicit type declarations.
o Dynamic typing with object references and downcasting.
4. Design
Class Diagram
The system consists of the following main classes:
Person (Base Class): Attributes: name, email, dateOfBirth.
o Student: Inherits from Person, adds studentID, enrolledCourses, methods like
enrollInCourse() and displayCourses().
o Teacher: Inherits from Person, adds teacherID, specialization, assignedCourses,
methods like assignCourse() and displayCourses().
o AdministrativeStaff: Inherits from Person, adds staffID, role, department,
methods like generateReport().
Course: Attributes: courseID, title, credits, assignedTeacher, students, methods like
addStudent(), removeStudent(), calculateAverageGrade().
Page | 3
University: Manages collections of students, teachers, and courses having static listss,
handles data loading and saving.
Repository: A generic class to manage lists of Student, Teacher, and Course objects.
Reportable: Interface defining methods generateReport() and exportToFile().
GUI Design
The system includes the following GUI components:
Main Menu: Buttons for navigating between the student, teacher, and administrative
interfaces.
Student Panel: Allows students to enroll in courses and view their enrolled courses.
Teacher Panel: Allows teachers to assign courses and view the courses they are teaching.
Administrative Panel: Allows staff to generate reports and manage the overall system.
Report Generation: Option to generate reports for students, teachers, or courses.
5. Implementation
Core Concepts Used
1. Inheritance: The base class Person allows the classes Student, Teacher, and
AdministrativeStaff to inherit common properties and methods, reducing redundancy.
2. Polymorphism: The generateReport() and displayDetails() methods demonstrate
polymorphism by providing class-specific implementations for generating reports and
displaying information.
3. Composition: The Course class is composed of a Teacher object and an array of Student
objects, emphasizing real-world relationships.
4. File Handling: The system uses file handling to save and retrieve data, ensuring
persistence of student, teacher, and course records.
Page | 4
Page | 5
Class Diagram
Page | 6
Implementation Code
Crud GUI
import javax.swing.*;
import java.awt.*;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.time.LocalDate;
import java.util.ArrayList;
public crud() {
JFrame frame = new JFrame("CRUD Application");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 400);
frame.setLayout(new BorderLayout());
Page | 7
JMenu studentMenu = new JMenu("Student");
JMenuItem addStudentMenuItem = new JMenuItem("Add Student");
JMenuItem viewStudentMenuItem = new JMenuItem("View Student by
ID");
JMenuItem updateStudentMenuItem = new JMenuItem("Update
Student by ID");
JMenuItem deleteStudentMenuItem = new JMenuItem("Delete Student
by ID");
studentMenu.add(addStudentMenuItem);
studentMenu.add(viewStudentMenuItem);
studentMenu.add(updateStudentMenuItem);
studentMenu.add(deleteStudentMenuItem);
Page | 8
JMenu courseMenu = new JMenu("Course");
JMenuItem addCourseMenuItem = new JMenuItem("Add Course");
JMenuItem viewCourseMenuItem = new JMenuItem("View Course by
ID");
JMenuItem updateCourseMenuItem = new JMenuItem("Update Course
by ID");
JMenuItem deleteCourseMenuItem = new JMenuItem("Delete Course
by ID");
courseMenu.add(addCourseMenuItem);
courseMenu.add(viewCourseMenuItem);
courseMenu.add(updateCourseMenuItem);
courseMenu.add(deleteCourseMenuItem);
menuBar.add(studentMenu);
menuBar.add(teacherMenu);
menuBar.add(courseMenu);
frame.setJMenuBar(menuBar);
Page | 9
// Student menu actions
addStudentMenuItem.addActionListener(e -> showAddStudentForm());
viewStudentMenuItem.addActionListener(e -> handleViewStudent());
updateStudentMenuItem.addActionListener(e ->
handleUpdateStudent());
deleteStudentMenuItem.addActionListener(e ->
handleDeleteStudent());
frame.setVisible(true);
Page | 10
}
// Course methods
private void handleAddCourse() {
dynamicPanel.removeAll();
dynamicPanel.add(courseNameLabel);
dynamicPanel.add(courseNameInput);
dynamicPanel.add(courseIdLabel);
dynamicPanel.add(courseIdInput);
dynamicPanel.add(courseCreditsLabel);
dynamicPanel.add(courseCreditsInput);
dynamicPanel.add(saveButton);
dynamicPanel.revalidate();
Page | 11
dynamicPanel.repaint();
saveButton.addActionListener(e -> {
try {
String courseName = courseNameInput.getText();
String courseId = courseIdInput.getText();
int courseCredits = Integer.parseInt(courseCreditsInput.getText());
if (courseName.isEmpty() || courseId.isEmpty()) {
JOptionPane.showMessageDialog(null, "All fields are required!",
"Error", JOptionPane.ERROR_MESSAGE);
return;
}
University.saveData("university_data.txt");
JOptionPane.showMessageDialog(null, "Course added
successfully!", "Success", JOptionPane.INFORMATION_MESSAGE);
courseNameInput.setText("");
courseIdInput.setText("");
courseCreditsInput.setText("");
Page | 12
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "Invalid input: " +
ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
});
}
dynamicPanel.add(courseNameLabel);
Page | 14
dynamicPanel.add(courseNameInput);
dynamicPanel.add(courseIdLabel);
dynamicPanel.add(courseIdInput);
dynamicPanel.add(courseCreditsLabel);
dynamicPanel.add(courseCreditsInput);
dynamicPanel.add(updateButton);
dynamicPanel.revalidate();
dynamicPanel.repaint();
updateButton.addActionListener(updateEvent -> {
try {
course.setCourseName(courseNameInput.getText());
course.setCourseId(courseIdInput.getText());
course.setCredits(Integer.parseInt(courseCreditsInput.getText()));
Page | 15
return;
}
}
JOptionPane.showMessageDialog(null, "Course not found!", "Error",
JOptionPane.ERROR_MESSAGE);
} else {
JOptionPane.showMessageDialog(null, "Please enter a valid Course
ID.", "Warning", JOptionPane.WARNING_MESSAGE);
}
}
// Loop through the course list to find and delete the course
for (int i = 0; i < courseList.size(); i++) {
if (courseList.get(i).getCourseId().equals(courseId)) {
courseList.remove(i);
found = true;
Page | 16
break;
}
}
Page | 17
private void writeCourseListToFile(ArrayList<Course> courseList) {
try (BufferedWriter writer = new BufferedWriter(new
FileWriter("university_data.txt"))) {
University.setCourseList(courseList);
for (Course course : courseList) {
// Assuming Course has a method to represent its data in a suitable
format
writer.write(course.getCourseName() + "|" + course.getCourseId() +
"|" + course.getCredits());
writer.newLine();
}
} catch (IOException e) {
JOptionPane.showMessageDialog(null, "Error updating course file.",
"Error", JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}
}
// Teacher methods
private void showAddTeacherForm() {
showFormForTeacher("Teacher", "Name", "Email", "Teacher ID",
"Date of Birth (YYYY-MM-DD)", "Address", "Specialization");
Page | 18
}
// Input fields
JLabel field1 = new JLabel(field1Label + ":");
JTextField field1Input = new JTextField(20);
JLabel field2 = new JLabel(field2Label + ":");
JTextField field2Input = new JTextField(20);
JLabel field3 = new JLabel(field3Label + ":");
JTextField field3Input = new JTextField(20);
JLabel field4 = new JLabel(field4Label + ":");
JTextField field4Input = new JTextField(20);
JLabel field5 = new JLabel(field5Label + ":");
JTextField field5Input = new JTextField(20);
JLabel field6 = new JLabel(field6Label + ":");
JTextField field6Input = new JTextField(20);
JButton saveButton = new JButton("Save");
Page | 19
dynamicPanel.add(field1);
dynamicPanel.add(field1Input);
dynamicPanel.add(field2);
dynamicPanel.add(field2Input);
dynamicPanel.add(field3);
dynamicPanel.add(field3Input);
dynamicPanel.add(field4);
dynamicPanel.add(field4Input);
dynamicPanel.add(field5);
dynamicPanel.add(field5Input);
dynamicPanel.add(field6);
dynamicPanel.add(field6Input);
dynamicPanel.add(saveButton);
dynamicPanel.revalidate();
dynamicPanel.repaint();
saveButton.addActionListener(e -> {
try {
String name = field1Input.getText();
String email = field2Input.getText();
String teacherId = field3Input.getText();
LocalDate dateOfBirth = LocalDate.parse(field4Input.getText());
Page | 20
String address = field5Input.getText();
String specialization = field6Input.getText();
Page | 21
field1Input.setText("");
field2Input.setText("");
field3Input.setText("");
field4Input.setText("");
field5Input.setText("");
field6Input.setText("");
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "Invalid input: " +
ex.getMessage(), "Error",
JOptionPane.ERROR_MESSAGE);
}
});
}
Page | 22
}
}
JOptionPane.showMessageDialog(null, "Teacher not found!", "Error",
JOptionPane.ERROR_MESSAGE);
} else {
JOptionPane.showMessageDialog(null, "Please enter a valid ID.",
"Warning", JOptionPane.WARNING_MESSAGE);
}
}
Page | 23
JTextField teacherIdInput = new JTextField(teacher.getTeacherId(),
20);
JLabel addressLabel = new JLabel("Address:");
JTextField addressInput = new JTextField(teacher.getAddress(),
20);
JLabel specializationLabel = new JLabel("Specialization:");
JTextField specializationInput = new
JTextField(teacher.getSpecialization(), 20);
JButton updateButton = new JButton("Update");
dynamicPanel.add(nameLabel);
dynamicPanel.add(nameInput);
dynamicPanel.add(emailLabel);
dynamicPanel.add(emailInput);
dynamicPanel.add(teacherIdLabel);
dynamicPanel.add(teacherIdInput);
dynamicPanel.add(addressLabel);
dynamicPanel.add(addressInput);
dynamicPanel.add(specializationLabel);
dynamicPanel.add(specializationInput);
dynamicPanel.add(updateButton);
dynamicPanel.revalidate();
dynamicPanel.repaint();
Page | 24
// Add action listener for the update button
updateButton.addActionListener(updateEvent -> {
try {
teacher.setName(nameInput.getText());
teacher.setEmail(emailInput.getText());
teacher.setTeacherId(teacherIdInput.getText());
teacher.setAddress(addressInput.getText());
teacher.setSpecialization(specializationInput.getText());
return;
Page | 25
}
}
JOptionPane.showMessageDialog(null, "Teacher not found!", "Error",
JOptionPane.ERROR_MESSAGE);
} else {
JOptionPane.showMessageDialog(null, "Please enter a valid Teacher
ID.", "Warning", JOptionPane.WARNING_MESSAGE);
}
}
Page | 26
}
}
if (teacherFound) {
// Update the list in University class
// You might not need to set it again; just modify the existing list
University.setTeacherList(teachers); // You can directly modify the
static list
Page | 27
private void updateTeacherFile(ArrayList<Teacher> teachers) {
try (BufferedWriter writer = new BufferedWriter(new
FileWriter("university_data.txt"))) {
for (Teacher teacher : teachers) {
// Assuming the file format for each teacher is: teacherId, name,
specialization
writer.write(teacher.getTeacherId() + "," + teacher.getName() + "," +
teacher.getSpecialization());
writer.newLine();
}
} catch (IOException e) {
JOptionPane.showMessageDialog(null, "Error updating teacher file.",
"Error", JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}
}
Page | 29
// Show the student update form
dynamicPanel.removeAll();
dynamicPanel.add(nameLabel);
dynamicPanel.add(nameInput);
dynamicPanel.add(emailLabel);
dynamicPanel.add(emailInput);
dynamicPanel.add(studentIdLabel);
dynamicPanel.add(studentIdInput);
Page | 30
dynamicPanel.add(addressLabel);
dynamicPanel.add(addressInput);
dynamicPanel.add(marksLabel);
dynamicPanel.add(marksInput);
dynamicPanel.add(updateButton);
dynamicPanel.revalidate();
dynamicPanel.repaint();
student.setMarks(Double.parseDouble(marksInput.getText()));
Page | 31
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "Invalid input: " +
ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
});
return;
}
}
JOptionPane.showMessageDialog(null, "Student not found!", "Error",
JOptionPane.ERROR_MESSAGE);
} else {
JOptionPane.showMessageDialog(null, "Please enter a valid Student
ID.", "Warning", JOptionPane.WARNING_MESSAGE);
}
}
Page | 32
University.setStudentList(students);
JOptionPane.showMessageDialog(null, "Student deleted
successfully!", "Success",
JOptionPane.INFORMATION_MESSAGE);
} else {
JOptionPane.showMessageDialog(null, "Please enter a valid ID.",
"Warning", JOptionPane.WARNING_MESSAGE);
}
}
// Input fields
JLabel field1 = new JLabel(field1Label + ":");
JTextField field1Input = new JTextField(20);
JLabel field2 = new JLabel(field2Label + ":");
JTextField field2Input = new JTextField(20);
JLabel field3 = new JLabel(field3Label + ":");
JTextField field3Input = new JTextField(20);
JLabel field4 = new JLabel(field4Label + ":");
JTextField field4Input = new JTextField(20);
Page | 33
JLabel field5 = new JLabel(field5Label + ":");
JTextField field5Input = new JTextField(20);
JLabel field6 = new JLabel(field6Label + ":");
JTextField field6Input = new JTextField(20);
JButton saveButton = new JButton("Save");
dynamicPanel.revalidate();
dynamicPanel.repaint();
Page | 34
saveButton.addActionListener(e -> {
try {
String name = field1Input.getText();
String email = field2Input.getText();
String studentId = field3Input.getText();
LocalDate dateOfBirth = LocalDate.parse(field4Input.getText());
String address = field5Input.getText();
double marks = Double.parseDouble(field6Input.getText());
Page | 35
JOptionPane.showMessageDialog(null, entity + " added
successfully!", "Success",
JOptionPane.INFORMATION_MESSAGE);
Page | 36
University university = new University("Tech Campus", students,
teachers, staff, courses);
new crud();
University.saveData("university_data.txt");
ArrayList<?> dataList = University.loadData("university_data.txt"); //
Load data as a generic list
Page | 37
}
}
// Now, you can use these lists to process or display the data as needed
System.out.println("Students:");
for (Student student : student1) {
System.out.println(student);
}
System.out.println("Teachers:");
for (Teacher teacher : teacher1) {
System.out.println(teacher);
}
System.out.println("Administrative Staff:");
for (AdministrativeStaff admin : staffs) {
System.out.println(admin);
}
System.out.println("Courses:");
for (Course course : course1) {
System.out.println(course);
}
Page | 38
}
}
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collections;
interface Reportable {
void generateReport();
class Repository<T> {
private ArrayList<T> items;
public Repository() {
this.items = new ArrayList<>();
Page | 39
}
public person() {
}
Page | 40
public person(String name, String email, LocalDate dateOfBirth, String ad)
{
this.name = name;
this.email = email;
this.dateOfBirth = dateOfBirth;
this.address = ad;
}
Page | 41
public void setEmail(String email) {
this.email = email;
}
@Override
public String toString() {
Page | 42
return "person [name=" + name + ", email=" + email + ", dateOfBirth=" +
dateOfBirth + "]";
}
public Student() {
University.StudentList.add(this);
}
Page | 43
}
Page | 44
this.courses = courses;
}
@Override
public String toString() {
return "Student [name=" + name + ", email=" + email + ", StudentId=" +
StudentId + ", marks=" + marks + "]";
}
Page | 45
}
}
class Course {
// Attributes: courseID, title, credits, assignedTeacher, list of enrolled
// students.
private String courseName;
private String courseId;
private double credits;
private ArrayList<Student> students;
private Teacher assignedteacher;
public Course() {
}
Page | 46
}
Page | 47
this.credits = credits;
}
Page | 48
if (students == null) {
students = new ArrayList<>(); // Initialize the list if it's null
}
if (students.contains(s)) {
throw new IllegalStateException("Student already enrolled in this
course: " + s.getStudentId());
}
this.students.add(s);
Page | 49
System.out.println("Student with ID " + s.getStudentId() + " not found
in the list.");
}
}
Page | 50
}
Collections.sort(grades);
@Override
public String toString() {
return "Course [courseName=" + courseName + ", courseId=" + courseId
+ ", credits=" + credits + "]";
Page | 51
}
}
public Teacher() {
Page | 52
University.TeacherList.add(this);
Page | 53
public void setSpecialization(String specialization) {
this.specialization = specialization;
}
Page | 54
// Check if the teacher is assigned to any courses
if (courses.isEmpty()) {
System.out.println("No courses assigned.");
} else {
for (Course course : courses) {
}
public String toString() {
return "Teacher [name=" + name + ", email=" + email + ", teacherId=" +
teacherId + ", teacherName="
+ teacherName + ", specialization=" + specialization + "]";
}
Page | 55
private String role;
private String department;
Page | 56
}
System.out.println("Report Summary:");
System.out.println("***************************");
Page | 57
System.out.println("Total Students: " +
University.totalStudentsEnrolled());
System.out.println("Total Teachers: " + University.totalTeachers());
System.out.println("Total Administrative Staff: " +
University.StaffList.size());
System.out.println("Total Courses: " + University.totalCourses());
System.out.println("\nCourse Details:");
for (Course course : University.CourseList) {
System.out.println("Course Name: " + course.getCourseName() +
", Total Students Who Enrolled in this Course: " +
course.getStudents().size() +
", Teacher Who is Teaching this Course: " +
course.getTeacher().getName() +
", Course ID: " + course.getCourseId() +
", Credits: " + course.getCredits());
}
}
public String toString() {
return "AdministrativeStaff [name=" + name + ", email=" + email + ",
staffID=" + staffID + ", role=" + role
+ ", department=" + department + "]";
}
}
Page | 58
public class semproject1 {
public static void main(String[] args) {
try {
// Example setup
ArrayList<Student> students = new ArrayList<>();
ArrayList<Teacher> teachers = new ArrayList<>();
ArrayList<AdministrativeStaff> staff = new ArrayList<>();
ArrayList<Course> courses = new ArrayList<>();
Page | 59
for (Object item : dataList) {
if (item instanceof Student) {
student1.add((Student) item);
} else if (item instanceof Teacher) {
teacher1.add((Teacher) item);
} else if (item instanceof AdministrativeStaff) {
staffs.add((AdministrativeStaff) item);
} else if (item instanceof Course) {
course1.add((Course) item);
}
}
// Now, you can use these lists to process or display the data as needed
System.out.println("Students:");
for (Student student : student1) {
System.out.println(student);
}
System.out.println("Teachers:");
for (Teacher teacher : teacher1) {
System.out.println(teacher);
}
Page | 60
System.out.println("Administrative Staff:");
for (AdministrativeStaff admin : staffs) {
System.out.println(admin);
}
System.out.println("Courses:");
for (Course course : course1) {
System.out.println(course);
}
university.generateReport();
} catch (IllegalArgumentException e) {
System.err.println("Invalid argument: " + e.getMessage());
} catch (IllegalStateException e) {
System.err.println("Illegal operation: " + e.getMessage());
} catch (Exception e) {
// Catch-all for unexpected errors
System.err.println("An unexpected error occurred: " +
e.getMessage());
e.printStackTrace();
Page | 61
} finally {
System.out.println("Program execution completed.");
}
}
}
University.java File
import java.util.ArrayList;
import java.io.*;
Page | 62
StaffList = staffList;
CourseList = courseList;
}
Page | 63
public static void setTeacherList(ArrayList<Teacher> teacherList) {
TeacherList = teacherList;
}
Page | 64
try (BufferedWriter writer = new BufferedWriter(new
FileWriter(filename, true))) {
// Save the last student, if present
if (!StudentList.isEmpty()) {
Student student = StudentList.get(StudentList.size() - 1);
writer.write("Student|Name:" + student.getName() + "|Email:" +
student.getEmail() + "|Address:" + student.getAddress() + "|Student ID:" +
student.getStudentId() + "|Marks:" + student.getMarks() + "\n");
}
Page | 65
}
Page | 66
String name = parts[1].split(":")[1];
String email = parts[2].split(":")[1];
String address = parts[3].split(":")[1];
String studentId = parts[4].split(":")[1];
double marks = Double.parseDouble(parts[5].split(":")[1]);
Student student = new Student(name, email, null, address,
studentId, marks, null);
dataList.add((T) student);
} else if (line.startsWith("Teacher")) {
String name = parts[1].split(":")[1];
String email = parts[2].split(":")[1];
String address = parts[3].split(":")[1];
String teacherId = parts[4].split(":")[1];
String specialization = parts[5].split(":")[1];
Teacher teacher = new Teacher(name, email, null, address,
teacherId, null, specialization, null);
dataList.add((T) teacher);
} else if (line.startsWith("AdministrativeStaff")) {
String name = parts[1].split(":")[1];
String email = parts[2].split(":")[1];
String address = parts[3].split(":")[1];
String staffID = parts[4].split(":")[1];
String role = parts[5].split(":")[1];
String department = parts[6].split(":")[1];
Page | 67
AdministrativeStaff staff = new AdministrativeStaff(name, email,
null, address, staffID, role, department);
dataList.add((T) staff);
} else if (line.startsWith("Course")) {
String courseName = parts[1].split(":")[1];
String courseId = parts[2].split(":")[1];
double credits = Double.parseDouble(parts[3].split(":")[1]);
Course course = new Course(courseName, courseId, credits, new
ArrayList<>(), null);
dataList.add((T) course);
}
}
System.out.println("Data successfully loaded from " + filename);
} catch (IOException e) {
System.err.println("Error loading data: " + e.getMessage());
}
return dataList;
}
Page | 68
}
}
return null; // Return null if not found
}
if (StudentList.contains(s)) {
Page | 69
throw new IllegalStateException("Student already enrolled in this
course: " + s.getStudentId());
}
StudentList.add(s);
if (!StudentList.contains(s)) {
throw new IllegalStateException("Student does not Exist");
}
StudentList.remove(s);
Page | 70
public static int totalStudentsEnrolled() {
return StudentList.size();
}
System.out.println("Report Summary:");
System.out.println("***************************");
Page | 71
System.out.println("Total Teachers: " + University.totalTeachers());
System.out.println("Total Administrative Staff: " +
University.StaffList.size());
System.out.println("Total Courses: " + University.totalCourses());
}
}
Page | 72