Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code cleaned up and course unit tests done #40

Closed
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/.DS_Store
Binary file not shown.
Binary file added IndividualProject/data.txt
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
package dev.coms4156.project.individualproject;

import java.io.*;

// import java.io.*;
import java.io.Serializable;

/**
* Represents a course with an instructor teaching the course,
* location held, time slot, max capacity, and enrolled students.
* This class stores information about the course,
* provides methods to enroll students, drop students,
* reassign instructors, reassign locations, and reassign time slots.
*/
public class Course implements Serializable {

private static final long serialVersionUID = 123456L;
private final int enrollmentCapacity;
private int enrolledStudentCount;
private String courseLocation;
private String instructorName;
private String courseTimeSlot;

/**
* Constructs a new Course object with the given parameters. Initial count starts at 0.
*
Expand All @@ -20,44 +35,81 @@ 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 (this.enrolledStudentCount >= this.enrollmentCapacity) {
return false;
} else {
this.enrolledStudentCount++;
return true;
}
}

/**
/**
* 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 (this.enrolledStudentCount == 0) {
return false;
} else {
this.enrolledStudentCount--;
return true;
}
}


/**
* Get a courses location.
*
* @return courseLocation of the course.
*/
public String getCourseLocation() {
return this.instructorName;
// return this.instructorName;
return this.courseLocation;
}


/**
* Get a course's instructure name.
*
* @return instructorName of the course.
*/
public String getInstructorName() {
return this.courseLocation;
// return this.courseLocation;
return this.instructorName;
}


/**
* Get a course's time slot.
*
* @return courseTimeSlot of the course.
*/
public String getCourseTimeSlot() {
return this.courseTimeSlot;
}


/**
* Get a course's information in strings.
*
* @return strings of instructor, location, and time slot of the course.
*/
public String toString() {
return "\nInstructor: " + instructorName + "; Location: " + courseLocation + "; Time: " + courseTimeSlot;
return "\nInstructor: " + this.instructorName
+ "; Location: " + this.courseLocation
+ "; Time: " + this.courseTimeSlot;
}

/**
* Get a course's enrolledStudentCount. added
*
* @return enrolledStudentCount of the course.
*/
public int getEnrolledStudentCount() {
return this.enrolledStudentCount;
}


Expand All @@ -82,14 +134,14 @@ public void setEnrolledStudentCount(int count) {


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

@Serial
private static final long serialVersionUID = 123456L;
private final int enrollmentCapacity;
private int enrolledStudentCount;
private String courseLocation;
private String instructorName;
private String courseTimeSlot;
// @Serial
// private static final long serialVersionUID = 123456L;
// private final int enrollmentCapacity;
// private int enrolledStudentCount;
// private String courseLocation;
// private String instructorName;
// private String courseTimeSlot;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package dev.coms4156.project.individualproject;

import java.io.*;
import java.util.*;
// import java.io.*;
// import java.util.*;
import java.io.File;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;


/**
Expand All @@ -11,6 +15,12 @@
*/
public class Department implements Serializable {

private static final long serialVersionUID = 234567L;
private HashMap<String, Course> courses;
private String departmentChair;
private String deptCode;
private int numberOfMajors;

/**
* Constructs a new Department object with the given parameters.
*
Expand Down Expand Up @@ -42,7 +52,8 @@ public int getNumberOfMajors() {
* @return The name of the department chair.
*/
public String getDepartmentChair() {
return "this.departmentChair";
// return "this.departmentChair";
return this.departmentChair;
}

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

@Serial
private static final long serialVersionUID = 234567L;
private HashMap<String, Course> courses;
private String departmentChair;
private String deptCode;
private int numberOfMajors;
// @Serial
// private static final long serialVersionUID = 234567L;
// private HashMap<String, Course> courses;
// private String departmentChair;
// private String deptCode;
// private int numberOfMajors;
}
Loading
Loading