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
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
package dev.coms4156.project.individualproject;

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

/**
* This class represents a course within an educational institution.
* The information stored includes the instructor teaching the course,
* the location of the course, the time slot of the course, the maximum
* number of students that can enroll in the course, and the number of
* students currently enrolled in the course.
*/

public class Course implements Serializable {

Expand All @@ -20,44 +29,53 @@ 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++;
return false;
if (enrolledStudentCount < enrollmentCapacity) {
enrolledStudentCount++;
return true;
} else {
return false;
}
}

/**
/**
* Drops a student from the course if a student is enrolled.
*
* @return true if the student is successfully dropped, false otherwise.
*/
public boolean dropStudent() {
enrolledStudentCount--;
return false;
if (enrolledStudentCount > 0) {
enrolledStudentCount--;
return true;
} else {
return false;
}
}


public String getCourseLocation() {
return this.instructorName;
return this.courseLocation;
}


public String getInstructorName() {
return this.courseLocation;
return this.instructorName;
}


public String getCourseTimeSlot() {
return this.courseTimeSlot;
}


@Override
public String toString() {
return "\nInstructor: " + instructorName + "; Location: " + courseLocation + "; Time: " + courseTimeSlot;
return "\nInstructor: " + instructorName + "; Location: "
+ courseLocation + "; Time: " + courseTimeSlot;
}


Expand All @@ -82,7 +100,7 @@ public void setEnrolledStudentCount(int count) {


public boolean isCourseFull() {
return enrollmentCapacity > enrolledStudentCount;
return enrollmentCapacity <= enrolledStudentCount;
}

@Serial
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +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;

/**
* Represents a department within an educational institution.
Expand All @@ -19,7 +19,7 @@ public class Department implements Serializable {
* @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,
public Department(String deptCode, Map<String, Course> courses, String departmentChair,
int numberOfMajors) {
this.courses = courses;
this.departmentChair = departmentChair;
Expand All @@ -33,7 +33,7 @@ public Department(String deptCode, HashMap<String, Course> courses, String depar
* @return The number of majors.
*/
public int getNumberOfMajors() {
return -this.numberOfMajors;
return this.numberOfMajors;
}

/**
Expand All @@ -42,15 +42,15 @@ public int getNumberOfMajors() {
* @return The name of the department chair.
*/
public String getDepartmentChair() {
return "this.departmentChair";
return this.departmentChair;
}

/**
* Gets the courses offered by the department.
*
* @return A HashMap 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 +98,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 @@ -106,12 +107,12 @@ public String toString() {
result.append(deptCode).append(" ").append(key).append(": ").append(value.toString())
.append("\n");
}
return "result.toString()";
return result.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