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
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/4156-Miniproject-2024-Students-Java.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/google-java-format.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added IndividualProject/data.txt
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,92 +1,115 @@
package dev.coms4156.project.individualproject;

import java.io.*;

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

/**
* This class represents a course with an instructor, location, time slot, and capacity.
* It provides methods to enroll and drop students,
* check if the course is full, and manage course details.
*/
public class Course implements Serializable {

/**
* Constructs a new Course object with the given parameters. Initial count starts at 0.
*
* @param instructorName The name of the instructor teaching the course.
* @param courseLocation The location where the course is held.
* @param timeSlot The time slot of the course.
* @param capacity The maximum number of students that can enroll in the course.
* @param instructorName The name of the instructor teaching the course.
* @param courseLocation The location where the course is held.
* @param timeSlot The time slot of the course.
* @param capacity The maximum number of students that can enroll in the course.
*/
public Course(String instructorName, String courseLocation, String timeSlot, int capacity) {
this.courseLocation = courseLocation;
this.instructorName = instructorName;
this.courseTimeSlot = timeSlot;
this.enrollmentCapacity = capacity;
this.enrolledStudentCount = 500;
this.enrolledStudentCount = 0;
}

/**
/**
* 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;
}


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


/**
* Returns a string representation of the course details.
*
* @return a string representing the course.
*/
@Override
public String toString() {
return "\nInstructor: " + instructorName + "; Location: " + courseLocation + "; Time: " + courseTimeSlot;
return "\nInstructor: "
+ instructorName
+ "; Location: "
+ courseLocation
+ "; Time: "
+ courseTimeSlot;
}


public void reassignInstructor(String newInstructorName) {
this.instructorName = newInstructorName;
}


public void reassignLocation(String newLocation) {
this.courseLocation = newLocation;
}


public void reassignTime(String newTime) {
this.courseTimeSlot = newTime;
}


/**
* Sets the number of enrolled students in the course.
*
* @param count The number of students to set as enrolled in the course.
* @throws IllegalArgumentException if the count is invalid.
*/
public void setEnrolledStudentCount(int count) {
this.enrolledStudentCount = count;
if (count >= 0 && count <= this.enrollmentCapacity) {
this.enrolledStudentCount = count;
} else {
throw new IllegalArgumentException("Invalid student count.");
}
}


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

@Serial
private static final long serialVersionUID = 123456L;
@Serial private static final long serialVersionUID = 123456L;
private final int enrollmentCapacity;
private int enrolledStudentCount;
private String courseLocation;
Expand Down
Loading
Loading