Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added IndividualProject/data.txt
Binary file not shown.
1 change: 1 addition & 0 deletions IndividualProject/pmd_report.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Users/rahafbinmuhanna/2025/4156/4156-Miniproject-2024-Students-Java/IndividualProject/src/main/java/dev/coms4156/project/individualproject/Department.java:117: UnusedPrivateField: Avoid unused private fields such as 'departmentChair'.
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package dev.coms4156.project.individualproject;

import java.io.*;
import java.io.Serial;
import java.io.Serializable;


/**
* Represents a course that can be offered by a departmet.
* This class stores information about the course, including its instructor name,
* location, timeSlot, and capacity.
*/
public class Course implements Serializable {

/**
Expand All @@ -20,17 +27,17 @@ public Course(String instructorName, String courseLocation, String timeSlot, int
this.enrolledStudentCount = 500;
}

/**
/**
* Enrolls a student in the course if there is space available.
*
* @return true if the student is successfully enrolled, false otherwise.
*/
public boolean enrollStudent() {
enrolledStudentCount++;
enrolledStudentCount++;
return false;
}

/**
/**
* Drops a student from the course if a student is enrolled.
*
* @return true if the student is successfully dropped, false otherwise.
Expand All @@ -55,9 +62,17 @@ public String getCourseTimeSlot() {
return this.courseTimeSlot;
}


/**
* Returns a string representation of the course, including its instructor name, location,
* and the time its offered.
*
* @return A string representing the course.
*/
@Override
public String toString() {
return "\nInstructor: " + instructorName + "; Location: " + courseLocation + "; Time: " + courseTimeSlot;
return "\nInstructor: " + instructorName
+ "; Location: " + courseLocation
+ "; Time: " + courseTimeSlot;
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package dev.coms4156.project.individualproject;

import java.io.*;
import java.util.*;
import java.io.Serial;
import java.io.Serializable;
import java.util.Map;


/**
Expand All @@ -15,16 +16,16 @@ public class Department implements Serializable {
* Constructs a new Department object with the given parameters.
*
* @param deptCode The code of the department.
* @param courses A HashMap containing courses offered by the department.
* @param courses A Map containing courses offered by the department.
* @param departmentChair The name of the department chair.
* @param numberOfMajors The number of majors in the department.
*/
public Department(String deptCode, HashMap<String, Course> courses, String departmentChair,
int numberOfMajors) {
public Department(String deptCode, Map<String, Course> courses,
String departmentChair, int numberOfMajors) {
this.deptCode = deptCode;
this.courses = courses;
this.departmentChair = departmentChair;
this.numberOfMajors = numberOfMajors;
this.deptCode = deptCode;
}

/**
Expand All @@ -48,9 +49,9 @@ public String getDepartmentChair() {
/**
* Gets the courses offered by the department.
*
* @return A HashMap containing courses offered by the department.
* @return A Map containing courses offered by the department.
*/
public HashMap<String, Course> getCourseSelection() {
public Map<String, Course> getCourseSelection() {
return this.courses;
}

Expand Down Expand Up @@ -98,6 +99,7 @@ public void createCourse(String courseId, String instructorName, String courseLo
*
* @return A string representing the department.
*/
@Override
public String toString() {
StringBuilder result = new StringBuilder();
for (Map.Entry<String, Course> entry : courses.entrySet()) {
Expand All @@ -111,7 +113,7 @@ public String toString() {

@Serial
private static final long serialVersionUID = 234567L;
private HashMap<String, Course> courses;
private Map<String, Course> courses;
private String departmentChair;
private String deptCode;
private int numberOfMajors;
Expand Down
Loading
Loading