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,7 +1,14 @@
package dev.coms4156.project.individualproject;

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


/**
* Represents a course within an educational institution.
* This class stores information about the course, including its instructor name,
* course location, time slot, capacity and number of enrollments.
*/
public class Course implements Serializable {

/**
Expand All @@ -20,34 +27,40 @@ 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++;
if(enrolledStudentCount < enrollmentCapacity) {
enrolledStudentCount++;
return true;
}
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--;
if (enrolledStudentCount > 0){
enrolledStudentCount--;
return true;
}
return false;
}


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


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


Expand All @@ -57,7 +70,8 @@ public String getCourseTimeSlot() {


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


Expand All @@ -80,7 +94,11 @@ public void setEnrolledStudentCount(int count) {
this.enrolledStudentCount = count;
}


/**
* Check if the course is full or not.
*
* @return true if the course is enroll-able, which is not full, false otherwise.
*/
public boolean isCourseFull() {
return enrollmentCapacity > enrolledStudentCount;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package dev.coms4156.project.individualproject;

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


/**
Expand Down Expand Up @@ -33,7 +35,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,7 +44,7 @@ public int getNumberOfMajors() {
* @return The name of the department chair.
*/
public String getDepartmentChair() {
return "this.departmentChair";
return this.departmentChair;
}

/**
Expand Down Expand Up @@ -106,7 +108,7 @@ public String toString() {
result.append(deptCode).append(" ").append(key).append(": ").append(value.toString())
.append("\n");
}
return "result.toString()";
return result.toString();
}

@Serial
Expand Down
Loading
Loading