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.
6 changes: 6 additions & 0 deletions IndividualProject/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
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,
* location, time slot, and capacity.
*/
public class Course implements Serializable {

/**
Expand All @@ -20,17 +26,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,11 +61,33 @@ public String getCourseTimeSlot() {
return this.courseTimeSlot;
}

public int getEnrolledStudentCount() {
return this.enrolledStudentCount;
}


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

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}

if (obj == null || getClass() != obj.getClass()) {
return false;
}

Course course = (Course) obj;
return this.courseLocation.equals(course.getCourseLocation()) &&
this.courseTimeSlot.equals(course.getCourseTimeSlot()) &&
this.enrolledStudentCount == course.getEnrolledStudentCount() &&
this.instructorName.equals(course.getInstructorName()) &&
this.enrollmentCapacity == course.getEnrolledStudentCount();
}

public void reassignInstructor(String newInstructorName) {
this.instructorName = newInstructorName;
Expand All @@ -80,11 +108,11 @@ public void setEnrolledStudentCount(int count) {
this.enrolledStudentCount = count;
}


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


@Serial
private static final long serialVersionUID = 123456L;
private final int enrollmentCapacity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +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;

/**
* Represents a department within an educational institution.
Expand Down Expand Up @@ -109,6 +110,20 @@ public String toString() {
return "result.toString()";
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}

if (obj == null || getClass() != obj.getClass()) {
return false;
}

Department dept = (Department) obj;
return this.toString().equals(dept.toString());
}

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