[go: up one dir, main page]

0% found this document useful (0 votes)
9 views7 pages

Mid Lab Report

The document is a mid lab report on a project titled 'University Course Management System using Java', submitted by M Mubashir Hassan. It outlines the implementation of a course management system using object-oriented programming principles, including classes for Person, Student, Professor, Course, and University, demonstrating inheritance and composition. The project successfully models the relationships between professors, students, and courses, while showcasing key object-oriented concepts such as encapsulation and abstraction.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views7 pages

Mid Lab Report

The document is a mid lab report on a project titled 'University Course Management System using Java', submitted by M Mubashir Hassan. It outlines the implementation of a course management system using object-oriented programming principles, including classes for Person, Student, Professor, Course, and University, demonstrating inheritance and composition. The project successfully models the relationships between professors, students, and courses, while showcasing key object-oriented concepts such as encapsulation and abstraction.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Mid Lab Report

Object Orientied Programming

Submitted by:

Name: M Mubashir Hassan


Roll No: FA23-BAI-034
Department: Computer Science
Semester: IV
Course: Object-Oriented Programming
Instructor: MAM Bushra Naz
Date: 29April,2025
Project Title:

University Course Management System using Java

Objective:

The primary goal of this project is to implement a simple university course management
system using Java principles of inheritance and composition. This system models people
(professors and students), their relationship to courses, and the overall structure of the
university.

Classes and Structure:

1. Person (Base Class)

The Person class serves as a superclass for all individuals in the system. It includes basic
personal information:

 String name
 int age
 String email

public class Person {


protected String name;
protected int age;
protected String email;

public Person(String name, int age, String email) {


this.name = name;
this.age = age;
this.email = email;
}

public void displayInfo() {


System.out.println("Name: " + name + ", Age: " + age + ", Email: " + email);
}
}

2. Student (Subclass of Person)


Inherits from Person and includes:

 String studentId
 String major

public class Student extends Person {

private String studentId;


private String major;

public Student(String name, int age, String email, String studentId, String major) {
super(name, age, email);
this.studentId = studentId;
this.major = major;
}

public void displayStudent() {


displayInfo();
System.out.println("Student ID: " + studentId + ", Major: " + major);
}

public String getStudentId() {


return studentId;
}
}

3. Professor (Subclass of Person)


Inherits from Person and includes:

 String employeeId
 String department

public class Professor extends Person {


private String employeeId;
private String department;

public Professor(String name, int age, String email, String employeeId, String department) {
super(name, age, email);
this.employeeId = employeeId;
this.department = department;
}

public void displayProfessor() {


displayInfo();
System.out.println("Employee ID: " + employeeId + ", Department: " + department);
}
}

4. Course (Composition Class)

The Course class models a course offered at the university. It contains:

 String courseCode
 String courseTitle
 Professor instructor (has-a relationship)
 List<Student> enrolledStudents (composition)

import java.util.ArrayList;
import java.util.List;

public class Course {


private String courseCode;
private String courseTitle;
private Professor instructor;
private List<Student> enrolledStudents;

public Course(String courseCode, String courseTitle, Professor instructor) {


this.courseCode = courseCode;
this.courseTitle = courseTitle;
this.instructor = instructor;
this.enrolledStudents = new ArrayList<>();
}

public void enrollStudent(Student student) {


enrolledStudents.add(student);
}

public void displayCourse() {


System.out.println("Course Code: " + courseCode + ", Title: " + courseTitle);
System.out.print("Instructor: ");
instructor.displayProfessor();
System.out.println("Enrolled Students:");
for (Student student : enrolledStudents) {
student.displayStudent();
}
}
}

5. University (Composition Class)

The University class holds a list of all offered courses:

 List<Course> courses
import java.util.ArrayList;
import java.util.List;

public class University {


private List<Course> courses;

public University() {
courses = new ArrayList<>();
}

public void addCourse(Course course) {


courses.add(course);
}

public void displayCourses() {


for (Course course : courses) {
course.displayCourse();
System.out.println("-----");
}
}
}

Functionality:

 Professors can be assigned as instructors to a course.


 Students can be enrolled in a course.
 The system maintains and displays information on all university courses, including
instructors and enrolled students.

Object-Oriented Concepts Used:

 Inheritance: Student and Professor classes inherit from Person.


 Composition: Course has a Professor and a list of Student objects. University
contains a list of Course objects.
 Encapsulation: Data is protected through appropriate use of access modifiers and
public methods.
 Abstraction: Real-world entities are abstracted into classes and relationships.

Sample Output:
Course Code: CS101, Title: Object Oriented Programming
Instructor: Name: Bushra Naz, Age: 35, Email: bushranaz@comsats.edu.pk
Employee ID: PRO123, Department: Computer Science
Enrolled Students:
Name: Mubashir, Age: 20, Email: mubashir@email.com
Student ID: STD001, Major: CS
Name: Hassan, Age: 21, Email: mubashir@email.com
Student ID: STD002, Major: CS

Conclusion:

This project successfully demonstrates object-oriented programming concepts to design a


modular, extendable university system. The use of inheritance and composition allows for
future expansion, such as adding grades, attendance, or administration modules.

You might also like