CSC 217 Lab 08 Integrate into Course
and Related Classes
Now that the CourseRoll
is complete, the Course
class should use it keep track of a Course
’s roll. This will require the use of a new parameter when constructing Course
: enrollmentCap
. Additionally, the enrollmentCap
should be stored with a course record. That means an update to CourseRecordIO
, CourseCatalog
, and the associated test files to add the enrollment capacity value.
Integrate CourseRoll
into Course
Follow the provided design to integrate CourseRoll
into the Course
class. You’ll add the parameter, roll
and the method getCourseRoll()
.
You should construct the CourseRoll
in the Course
constructor(s). This will require a new parameter, enrollmentCap
, which should follow the instructorId
parameter. For the moment, this will break CourseRecordIO
, CourseCatalog
, and various tests. Work through the changes carefully as outlined below.
Additionally, update or add the following methods in Course
:
- Update
Course.toString()
to include theenrollmentCap
fromroll
after theinstructorId
in the comma separate value string. - Update
Course.getShortDisplayArray()
to include a 5th element (index 4) containing the open seats in theCourse
’sCourseRoll
. - Add the
getCourseRoll()
method. It should return aCourseRoll
object.
Once Course
compiles, update your test cases to include a value for the enrollmentCap
parameter. You’ll need to change all test files that construct a Course
object to use an enrollmentCap
.
You should also add test cases for:
- Ensuring a correct
enrollmentCap
or that anIllegalArgumentException
is thrown if theenrollmentCap
is out of bounds as described in the requirements. - Ensuring that you updates to the
toString()
method is correct. - Ensuring that the
getShortDisplayArray()
is now returning an array of length 5 and the contents are correct.
Run your Course
tests in isolation. Once they compile, and you update as described above, they should pass with no regressions.
Update CourseRecordIO
and CourseRecordIOTest
Now that there is an enrollment cap, you should update your test files for CourseRecordIO
. Download new copies of the CourseRecordIOTest
files:
Update the CourseRecordIO.readCourse()
method to handle the enrollmentCap
in a line of input. You may also need to update CourseRecordIOTest
if you have any calls to the Course
constructor.
Once CourseRecordIO
and CourseRecordIOTest
compile, run CourseRecordIOTest
in isolation. The tests should pass with no regressions.
Update CourseCatalog
and CourseCatalogTest
CourseCatalog
and CourseCatalogTest
also require updates.
- Add an
enrollmentCap
parameter after theinstructorId
parameter and update the call to theCourse
constructor inCourseCatalog
. - Update
getCourseCatalog()
to return a 5th column with the number of remaining seats. If you already delegate toCourse.getShortDisplayArray()
, no change will be needed unless you hardcoded the columns in the array to 4. If you do not delegate toCourse.getShortDisplayArray()
, you should do so!
CourseCatalogTest
should change all calls to the Course
constructor to add an enrollment cap. Update your tests accordingly. You may need to change your expected results file:
Fix Other Compiler Errors
Change the CourseCatalogPanel GUI file to remove any additional compiler errors related to the Course
and enrollmentCap
functionality.
Update any additional tests, like RegistrationManagerTest
, that need the enrollment capacity.
Make sure that all code is compiling and all tests are passing before moving on.
Push to GitHub
Push your PackScheduler
project to GitHub
- Add the unstaged changes to the index.
- Commit and push changes. Remember to use a meaningful commit message describing how you have changed the code.
Reminder: Staging and Pushing to GitHub
GitHub Resources: