diff --git a/IndividualProject/data.txt b/IndividualProject/data.txt
new file mode 100644
index 00000000..99f11c15
Binary files /dev/null and b/IndividualProject/data.txt differ
diff --git a/IndividualProject/pom.xml b/IndividualProject/pom.xml
index 6d87d4c9..9ee6054e 100644
--- a/IndividualProject/pom.xml
+++ b/IndividualProject/pom.xml
@@ -27,6 +27,11 @@
spring-boot-starter-test
test
+
+ jakarta.annotation
+ jakarta.annotation-api
+ 2.1.1
+
@@ -80,8 +85,8 @@
org.apache.maven.plugins
maven-compiler-plugin
- 17
- 17
+ 7
+ 7
diff --git a/IndividualProject/src/main/java/dev/coms4156/project/individualproject/Course.java b/IndividualProject/src/main/java/dev/coms4156/project/individualproject/Course.java
index 272c94c9..5f279fcc 100644
--- a/IndividualProject/src/main/java/dev/coms4156/project/individualproject/Course.java
+++ b/IndividualProject/src/main/java/dev/coms4156/project/individualproject/Course.java
@@ -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 location,
+ * instructor name, time slot, and enrollment capacity.
+ */
public class Course implements Serializable {
/**
@@ -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.
diff --git a/IndividualProject/src/main/java/dev/coms4156/project/individualproject/Department.java b/IndividualProject/src/main/java/dev/coms4156/project/individualproject/Department.java
index 4bab0f08..c98ee691 100644
--- a/IndividualProject/src/main/java/dev/coms4156/project/individualproject/Department.java
+++ b/IndividualProject/src/main/java/dev/coms4156/project/individualproject/Department.java
@@ -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.
diff --git a/IndividualProject/src/main/java/dev/coms4156/project/individualproject/IndividualProjectApplication.java b/IndividualProject/src/main/java/dev/coms4156/project/individualproject/IndividualProjectApplication.java
index 80860423..2423db89 100644
--- a/IndividualProject/src/main/java/dev/coms4156/project/individualproject/IndividualProjectApplication.java
+++ b/IndividualProject/src/main/java/dev/coms4156/project/individualproject/IndividualProjectApplication.java
@@ -1,10 +1,12 @@
package dev.coms4156.project.individualproject;
import jakarta.annotation.PreDestroy;
-import java.util.*;
-import org.springframework.boot.*;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import java.util.HashMap;
+
/**
* Class contains all the startup logic for the application.
*
@@ -34,13 +36,13 @@ public static void main(String[] args) {
* @param args A {@code String[]} of any potential runtime args
*/
public void run(String[] args) {
- for (String arg : args) {
- if (arg.equals("setup")) {
- myFileDatabase = new MyFileDatabase(1, "./data.txt");
- resetDataFile();
- System.out.println("System Setup");
- return;
- }
+ for (String arg : args) {
+ if (arg.equals("setup")) {
+ myFileDatabase = new MyFileDatabase(1, "./data.txt");
+ resetDataFile();
+ System.out.println("System Setup");
+ return;
+ }
}
myFileDatabase = new MyFileDatabase(0, "./data.txt");
System.out.println("Start up");
@@ -48,20 +50,20 @@ public void run(String[] args) {
/**
* Overrides the database reference, used when testing.
- *
- * @param testData A {@code MyFileDatabase} object referencing test data.
- */
- public static void overrideDatabase(MyFileDatabase testData) {
- myFileDatabase = testData;
- saveData = false;
- }
+ *
+ * @param testData A {@code MyFileDatabase} object referencing test data.
+ */
+ public static void overrideDatabase(MyFileDatabase testData) {
+ myFileDatabase = testData;
+ saveData = false;
+ }
- /**
- * Allows for data to be reset in event of errors.
- */
- public void resetDataFile() {
- String[] times = {"11:40-12:55", "4:10-5:25", "10:10-11:25", "2:40-3:55"};
- String[] locations = {"417 IAB", "309 HAV", "301 URIS"};
+ /**
+ * Allows for data to be reset in event of errors.
+ */
+ public void resetDataFile() {
+ String[] times = {"11:40-12:55", "4:10-5:25", "10:10-11:25", "2:40-3:55"};
+ String[] locations = {"417 IAB", "309 HAV", "301 URIS"};
//data for coms dept
Course coms1004 = new Course("Adam Cannon", locations[0], times[0], 400);
@@ -129,20 +131,20 @@ public void resetDataFile() {
ieor2500.setEnrolledStudentCount(52);
Course ieor3404 = new Course("Christopher J Dolan", "303 MUDD", times[2], 73);
ieor3404.setEnrolledStudentCount(80);
- Course ieor3658 = new Course("Daniel Lacker", "310 FAY", times[2], 96);
- ieor3658.setEnrolledStudentCount(87);
- Course ieor4102 = new Course("Antonius B Dieker", "209 HAM", times[2], 110);
- ieor4102.setEnrolledStudentCount(92);
- Course ieor4106 = new Course("Kaizheng Wang", "501 NWC", times[2], 150);
- ieor4106.setEnrolledStudentCount(161);
+ Course ieor3658 = new Course("Daniel Lacker", "310 FAY", times[2], 96);
+ ieor3658.setEnrolledStudentCount(87);
+ Course ieor4102 = new Course("Antonius B Dieker", "209 HAM", times[2], 110);
+ ieor4102.setEnrolledStudentCount(92);
+ Course ieor4106 = new Course("Kaizheng Wang", "501 NWC", times[2], 150);
+ ieor4106.setEnrolledStudentCount(161);
Course ieor4405 = new Course("Yuri Faenza", "517 HAV", times[0], 80);
- ieor4405.setEnrolledStudentCount(19);
- Course ieor4511 = new Course("Michael Robbins", "633 MUDD", "9:00-11:30", 150);
- ieor4511.setEnrolledStudentCount(50);
- Course ieor4540 = new Course("Krzysztof M Choromanski", "633 MUDD", "7:10-9:40", 60);
- ieor4540.setEnrolledStudentCount(33);
+ ieor4405.setEnrolledStudentCount(19);
+ Course ieor4511 = new Course("Michael Robbins", "633 MUDD", "9:00-11:30", 150);
+ ieor4511.setEnrolledStudentCount(50);
+ Course ieor4540 = new Course("Krzysztof M Choromanski", "633 MUDD", "7:10-9:40", 60);
+ ieor4540.setEnrolledStudentCount(33);
- courses = new HashMap<>();
+ courses = new HashMap<>();
courses.put("2500", ieor2500);
courses.put("3404", ieor3404);
courses.put("3658", ieor3658);
@@ -249,21 +251,29 @@ public void resetDataFile() {
mapping.put("ELEN", elen);
//data for psyc dept
- Course psyc1001 = new Course("Patricia G Lindemann", "501 SCH", "1:10-2:25", 200);
+ Course psyc1001 = new Course("Patricia G Lindemann", "501 SCH",
+ "1:10-2:25", 200);
psyc1001.setEnrolledStudentCount(191);
- Course psyc1610 = new Course("Christopher Baldassano", "200 SCH", times[2], 45);
+ Course psyc1610 = new Course("Christopher Baldassano", "200 SCH",
+ times[2], 45);
psyc1610.setEnrolledStudentCount(42);
- Course psyc2235 = new Course("Katherine T Fox-Glassman", "501 SCH", times[0], 125);
+ Course psyc2235 = new Course("Katherine T Fox-Glassman", "501 SCH",
+ times[0], 125);
psyc2235.setEnrolledStudentCount(128);
- Course psyc2620 = new Course("Jeffrey M Cohen", "303 URIS", "1:10-3:40", 60);
+ Course psyc2620 = new Course("Jeffrey M Cohen", "303 URIS",
+ "1:10-3:40", 60);
psyc2620.setEnrolledStudentCount(55);
- Course psyc3212 = new Course("Mayron Piccolo", "200 SCH", "2:10-4:00", 15);
+ Course psyc3212 = new Course("Mayron Piccolo", "200 SCH",
+ "2:10-4:00", 15);
psyc3212.setEnrolledStudentCount(15);
- Course psyc3445 = new Course("Mariam Aly", "405 SCH", "2:10-4:00", 12);
+ Course psyc3445 = new Course("Mariam Aly", "405 SCH",
+ "2:10-4:00", 12);
psyc3445.setEnrolledStudentCount(12);
- Course psyc4236 = new Course("Trenton Jerde", "405 SCH", "6:10-8:00", 18);
+ Course psyc4236 = new Course("Trenton Jerde", "405 SCH",
+ "6:10-8:00", 18);
psyc4236.setEnrolledStudentCount(17);
- Course psyc4493 = new Course("Jennifer Blaze", "200 SCH", "2:10-4:00", 15);
+ Course psyc4493 = new Course("Jennifer Blaze", "200 SCH",
+ "2:10-4:00", 15);
psyc4493.setEnrolledStudentCount(9);
courses = new HashMap<>();
diff --git a/IndividualProject/src/main/java/dev/coms4156/project/individualproject/RouteController.java b/IndividualProject/src/main/java/dev/coms4156/project/individualproject/RouteController.java
index 09f504dc..282283bb 100644
--- a/IndividualProject/src/main/java/dev/coms4156/project/individualproject/RouteController.java
+++ b/IndividualProject/src/main/java/dev/coms4156/project/individualproject/RouteController.java
@@ -1,8 +1,14 @@
package dev.coms4156.project.individualproject;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PatchMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
import java.util.HashMap;
-import org.springframework.http.*;
-import org.springframework.web.bind.annotation.*;
/**
* This class contains all the API routes for the system.
@@ -263,7 +269,8 @@ public ResponseEntity> findCourseInstructor(@RequestParam(value = "deptCode")
* indicating the proper response.
*/
@GetMapping(value = "/findCourseTime", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity> findCourseTime(@RequestParam(value = "deptCode") String deptCode, @RequestParam(value = "courseCode") int courseCode) {
+ public ResponseEntity> findCourseTime(@RequestParam(value = "deptCode") String deptCode,
+ @RequestParam(value = "courseCode") int courseCode) {
try {
boolean doesCourseExists;
doesCourseExists = retrieveCourse(deptCode, courseCode).getStatusCode() == HttpStatus.OK;
@@ -451,7 +458,9 @@ public ResponseEntity> changeCourseTime(@RequestParam(value = "deptCode") Stri
* successful, or an error message if the course is not found
*/
@PatchMapping(value = "/changeCourseTeacher", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity> changeCourseTeacher(@RequestParam(value = "deptCode") String deptCode, @RequestParam(value = "courseCode") int courseCode, @RequestParam(value = "teacher") String teacher) {
+ public ResponseEntity> changeCourseTeacher(@RequestParam(value = "deptCode") String deptCode,
+ @RequestParam(value = "courseCode") int courseCode,
+ @RequestParam(value = "teacher") String teacher) {
try {
boolean doesCourseExists;
doesCourseExists = retrieveCourse(deptCode, courseCode).getStatusCode() == HttpStatus.OK;
@@ -473,9 +482,23 @@ public ResponseEntity> changeCourseTeacher(@RequestParam(value = "deptCode") S
}
}
-
+ /**
+ * Endpoint for changing the location of a course.
+ * This method handles PATCH requests to change the instructor of a course identified by
+ * department code and course code. If the course exists, its instructor is updated to the
+ * provided instructor.
+ *
+ * @param deptCode the code of the department containing the course
+ * @param courseCode the code of the course to change the instructor for
+ * @param location the location to instruct the course
+ *
+ * @return a ResponseEntity with a success message if the operation is
+ * successful, or an error message if the course is not found
+ */
@PatchMapping(value = "/changeCourseLocation", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity> changeCourseLocation(@RequestParam(value = "deptCode") String deptCode, @RequestParam(value = "courseCode") int courseCode, @RequestParam(value = "location") String location) {
+ public ResponseEntity> changeCourseLocation(@RequestParam(value = "deptCode") String deptCode,
+ @RequestParam(value = "courseCode") int courseCode,
+ @RequestParam(value = "location") String location) {
try {
boolean doesCourseExists;
doesCourseExists = retrieveCourse(deptCode, courseCode).getStatusCode() == HttpStatus.OK;
diff --git a/IndividualProject/src/test/java/dev/coms4156/project/individualproject/CourseUnitTests.java b/IndividualProject/src/test/java/dev/coms4156/project/individualproject/CourseUnitTests.java
index 4edd00f9..a0de776d 100644
--- a/IndividualProject/src/test/java/dev/coms4156/project/individualproject/CourseUnitTests.java
+++ b/IndividualProject/src/test/java/dev/coms4156/project/individualproject/CourseUnitTests.java
@@ -1,10 +1,11 @@
package dev.coms4156.project.individualproject;
-import org.junit.jupiter.api.*;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
@SpringBootTest
@ContextConfiguration
diff --git a/README.md b/README.md
index 93e4ba9b..22751b15 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,5 @@
# Welcome Students of 4156
Please follow the assignment specifications on Courseworks when completing this project.
+
+## modification of readme
\ No newline at end of file