WolfScheduler Implementation
For the implementation phase of development, you will implement the provided design so that all of the pieces of the project work as a coherent whole.
For each Guided Project, you will be provided with a set of files like the GUI (provided in this section) and test files (provided in the testing section).
Guided Project 1
Guided Project 1 will walk you through the creation of the WolfScheduler
project, but an overview of each class and method are provided here. Note that all getters and setters for the fields are assumed. All setters must be implemented so that they do not break any invariants from the requirements (e.g., Course.setTitle()
should not allow title
to be set to null
or empty string).
edu.ncsu.csc216.wolf_scheduler.course
Unless otherwise noted, all constants and fields are private
and all methods are public
. Constants should be static
and final
. There are no static methods in the Course
class.
Course
Constants & Fields
SECTION_LENGTH
: constant containing the length of thesection
String
, which is a value of 3MAX_NAME_LENGTH
: constant containing the maximum length of thename
String
, which is a value of 6MIN_NAME_LENGTH
: constant containing the minimum length of thename
String
, which is a value of 4MAX_CREDITS
: constant containing the maximum number of credits for a course, which is a value of 5MIN_CREDITS
: constant containing the minimum number of credits for a course, which is a value of 1UPPER_TIME
: constant containing the upper military time, which is a value of 2400UPPER HOUR
: constant containing the upper value for an hour, which is a value of 60name
:String
containing theCourse
’s nametitle
:String
containing theCourse
’s titlesection
:String
containing theCourse
’s sectioncredits
:int
containing theCourse
’s credit hoursinstructorId
:String
containing theCourse
’s instructor idmeetingDays
:String
containing theCourse
’s meeting daysstartTime
:int
containing theCourse
’s start timeendTime
:int
containing theCourse
’s end time
Course
Constructors
Course(String name, String title, String section, int credits, String instructorId, String meetingDays, int startTime, int endTime)
: Sets the fields to the given values or throws anIllegalArgumentException
if provided an invalid value.Course(String name, String title, String section, int credits, String instructorId, String meetingDays)
: Sets the fields to the given values or throws anIllegalArgumentException
if provided an invalid value. The values ofstartTime
andendTime
are set to 0.
Course
Methods
- Each field has a getter, which returns the field. There is no special logic to any of the getters, so they are not listed individually.
setName()
: a private method that throws anIllegalArgumentException
if the parameter is null or less than theMIN_NAME_LENGTH
or greater than theMAX_NAME_LENGTH
.setTitle()
: throws anIllegalArgumentException
if the parameter is null or an emptyString
.setSection()
: throws anIllegalArgumentException
if the parameter is null or has a length not equal toSECTION_LENGTH
.setCredits()
: throws anIllegalArgumentException
if the parameter is less thanMIN_CREDITS
or greater thanMAX_CREDITS
setInstructorId()
: throws anIllegalArgumentException
if the parameter is null or an emptyString
.setMeetingDays()
: throws anIllegalArgumentException
if the parameter is null or an emptyString
; if the parameter contains a character other thanM
,T
,W
,H
,F
, orA
; and if when the parameter contains anA
, it is not the only character in theString
setCourseTime()
: throws anIllegalArgumentException
if thestartTime
orendTime
is not between 0 andUPPER_TIME
or if the last two digits of the time are greater than or equal toUPPER_HOUR
(e.g., 1478 would be an invalid time).getMeetingString()
: Returns aString
representation of theCourse
meeting time as outlined in [UC2, S7] and [UC3, S1].hashCode()
andequals()
: Use Eclipse to generatehashCode()
andequals()
on all fields.toString()
: Returns a comma separated list ofCourse
fields in the format expected in [UC1, S1].
edu.ncsu.csc216.wolf_scheduler.io
CourseRecordIO
provides a set of behaviors that should be available without creating an instance of a class. Additionally, the methods only rely on the provided parameters and not on any state associated with CourseRecordIO
. Therefore, all methods in CourseRecordIO
are static. That means any class in the project can access a method in a static way: CourseRecordIO.readCourseRecords()
and CourseRecordIO.writeCourseRecords()
.
CourseRecordIO
Methods
readCourseRecords(String fileName)
: Returns anArrayList
of validCourse
s read from the given file name. The method throws aFileNotFoundException
if the given file doesn’t exist.readCourse(String line)
: Returns aCourse
object created by parsing the line of text. This is aprivate
helper method ofreadCourseRecords()
. Since the method isprivate
, you are not required to have it in your implementation, but it does simplify the program.writeCourseRecords(String fileName, ArrayList<Course> courses)
: Writes the given list ofCourse
s to the given file. Throws anIOException
if unable to write to the file.
edu.ncsu.csc216.wolf_scheduler.scheduler
WolfScheduler
Constants & Fields
catalog
:ArrayList
ofCourse
s that make up the course catalog.schedule
:ArrayList
ofCourse
s that make up a student’s schedule. ThisArrayList
is a subset of thecatalog
.title
:String
representing the schedule’s title.
WolfScheduler
Constructors
WolfScheduler(String courseRecordsFileName)
: Initializesschedule
to an emptyArrayList
and setstitle
toMy Schedule
. Initializes thecatalog
ArrayList
and populates theCourse
s in the catalog from the information in thecourseRecordsFileName
. Throws anIllegalArgumentException
if the file cannot be found.
WolfScheduler
Methods
getCourseFromCatalog(String name, String section)
: Uses thename
andsection
to find aCourse
in thecatalog
. Returnsnull
if theCourse
cannot be found.addCourse(String name, String section)
: Returnstrue
if theCourse
represented by thename
andsection
are in thecatalog
and can be added to theschedule
andfalse
if theCourse
is not in thecatalog
. If there is aCourse
with the samename
already in theschedule
anIllegalArgumentException
is thrown.removeCourse(String name, String section)
: Returnstrue
if theCourse
is removed from theschedule
andfalse
otherwise.resetSchedule()
: Resets theschedule
to an emptyArrayList
.getCourseCatalog()
: Returns aString[][]
(2D array) that contains acatalog
item on each row. The first column is theCourse
name
, the second is thesection
, and the third is thetitle
.getScheduledCourses()
: Returns aString[][]
(2D array) that contains aschedule
item on each row. The first column is theCourse
name
, the second is thesection
, and the third is thetitle
.getFullScheduledCourses()
: Returns aString[][]
(2D array) that contains aschedule
item on each row. The first column is theCourse
name
, the second is thesection
, the third is thetitle
, the fourth is thecredits
, the fifth is theinstructorId
, and the sixth is the meeting timeString
.setTitle(String title)
: Throws anIllegalArgumentException
if the scheduletitle
is null.getTitle()
: Returns the scheduletitle
.exportSchedule(String fileName)
: Writes theschedule
to the given file.
edu.ncsu.csc216.wolf_scheduler.ui
Guided Project 2
Guided Project 2 will walk you through the addition of Event
s to the WolfScheduler
project, but an overview of the changes from Guided Project 1 are listed below. Note that all getters and setters for the fields are assumed. All setters must be implemented so that they do not break any invariants from the requirements (e.g., Course.setTitle()
should not allow title
to be set to null
or empty string).
edu.ncsu.csc216.wolf_scheduler.course
Unless otherwise noted, all constants and fields are private
and all methods are public
. Constants should be static
and final
. There are no static methods in the Activity
hierarchy.
Activity
Constants & Fields
UPPER_TIME
: constant containing the upper military time, which is a value of 2400UPPER HOUR
: constant containing the upper value for an hour, which is a value of 60title
:String
containing theCourse
’s titlemeetingDays
:String
containing theCourse
’s meeting daysstartTime
:int
containing theCourse
’s start timeendTime
:int
containing theCourse
’s end time
Activity
Constructors
Activity(String title, String meetingDays, int startTime, int endTime)
: Sets the fields to the given values or throws anIllegalArgumentException
if provided an invalid value.
Activity
Methods
- Each field has a getter, which returns the field. There is no special logic to any of the getters, so they are not listed individually.
setTitle()
: throws anIllegalArgumentException
if the parameter is null or an emptyString
.setMeetingDays()
: sets themeetingDays
field.setActivityTime()
: throws anIllegalArgumentException
if thestartTime
orendTime
is not between 0 andUPPER_TIME
or if the last two digits of the time are greater than or equal toUPPER_HOUR
(e.g., 1478 would be an invalid time).getMeetingString()
: Returns aString
representation of the meeting time as outlined in [UC2, S7] and [UC3, S1].hashCode()
andequals()
: Use Eclipse to generatehashCode()
andequals()
on all fields.getShortDisplayArray()
: Abstract method that returns an array ofString
s.getLongDisplayArray()
: Abstract method that returns an array ofString
s.isDuplicate()
: Abstract method that returns true if the givenActivity
is a duplicate of this object.
Course
Constants & Fields
SECTION_LENGTH
: constant containing the length of thesection
String
, which is a value of 3MAX_NAME_LENGTH
: constant containing the maximum length of thename
String
, which is a value of 6MIN_NAME_LENGTH
: constant containing the minimum length of thename
String
, which is a value of 4MAX_CREDITS
: constant containing the maximum number of credits for a course, which is a value of 5MIN_CREDITS
: constant containing the minimum number of credits for a course, which is a value of 1name
:String
containing theCourse
’s namesection
:String
containing theCourse
’s sectioncredits
:int
containing theCourse
’s credit hoursinstructorId
:String
containing theCourse
’s instructor id
Course
Constructors
Course(String name, String title, String section, int credits, String instructorId, String meetingDays, int startTime, int endTime)
: Sets the fields to the given values or throws anIllegalArgumentException
if provided an invalid value.Course(String name, String title, String section, int credits, String instructorId, String meetingDays)
: Sets the fields to the given values or throws anIllegalArgumentException
if provided an invalid value. The values ofstartTime
andendTime
are set to 0.
Course
Methods
- Each field has a getter, which returns the field. There is no special logic to any of the getters, so they are not listed individually.
setName()
: a private method that throws anIllegalArgumentException
if the parameter is null or less than theMIN_NAME_LENGTH
or greater than theMAX_NAME_LENGTH
.setSection()
: throws anIllegalArgumentException
if the parameter is null or has a length not equal toSECTION_LENGTH
.setCredits()
: throws anIllegalArgumentException
if the parameter is less thanMIN_CREDITS
or greater thanMAX_CREDITS
setInstructorId()
: throws anIllegalArgumentException
if the parameter is null or an emptyString
.setMeetingDays()
: overridesActivity
’ssetMeetingDays()
. Throws anIllegalArgumentException
if the parameter is null or an emptyString
; if the parameter contains a character other thanM
,T
,W
,H
,F
, orA
; and if when the parameter contains anA
, it is not the only character in theString
hashCode()
andequals()
: Use Eclipse to generatehashCode()
andequals()
on all fields.toString()
: Returns a comma separated list ofCourse
fields in the format expected in [UC1, S1] and [UC3, S2].getShortDisplayArray()
: Returns an array ofString
s containingname
,section
,title
, and meeting stringgetLongDisplayArray()
: Returns an array ofString
s containingname
,section
,title
,credits
,instructorId
, meeting string, and empty string.isDuplicate()
: Returns true if the givenActivity
is a duplicate of theCourse
byname
.
Event
Constants & Fields
weeklyRepeat
: int that describes how many weeks between eventseventDetails
:String
containing the event details
Event
Constructor
Event(String title, String meetingDays, int startTime, int endTime, int weeklyRepeat, String eventDetails)
: Sets the fields to the given values or throws anIllegalArgumentException
if provided an invalid value.
Event
Methods
- Each field has a getter, which returns the field. There is no special logic to any of the getters, so they are not listed individually.
setWeeklyRepeat()
: throws anIllegalArgumentException
if the parameter is less than one or greater than 4.setEventDetails()
: throws anIllegalArgumentException
if the parameter is null.setMeetingDays()
: overridesActivity
’ssetMeetingDays()
. Throws anIllegalArgumentException
if the parameter is null or an emptyString
; if the parameter contains a character other thanS
,M
,T
,W
,H
,F
, orS
.getMeetingString()
: overridesActivity
’sgetMeetingString()
and appends “ (every X weeks)” where X is theweeklyRepeat
.toString()
: Returns a comma separated list ofEvent
fields in the format expected in expected in [UC3, S2].getShortDisplayArray()
: Returns an array ofString
s containing empty string, empty string,title
, and meeting stringgetLongDisplayArray()
: Returns an array ofString
s containing empty string, empty string,title
, empty string, empty string, meeting string, and event details.isDuplicate()
: Returns true if the givenActivity
is a duplicate of theEvent
bytitle
.
edu.ncsu.csc216.wolf_scheduler.io
CourseRecordIO
and ActivityRecordIO
provide a set of behaviors that should be available without creating an instance of a class. Additionally, the methods only rely on the provided parameters and not on any state associated with the classes. Therefore, all methods in CourseRecordIO
and ActivityRecordIO
are static. That means any class in the project can access a method in a static way: CourseRecordIO.readCourseRecords()
and ActivityRecordIO.writeCourseRecords()
.
CourseRecordIO
Methods
readCourseRecords(String fileName)
: Returns anArrayList
of validCourse
s read from the given file name. The method throws aFileNotFoundException
if the given file doesn’t exist.readCourse(String line)
: Returns aCourse
object created by parsing the line of text. This is aprivate
helper method ofreadCourseRecords()
. Since the method isprivate
, you are not required to have it in your implementation, but it does simplify the program.
ActivityRecordIO
Methods
writeCourseRecords(String fileName, ArrayList<Activity> courses)
: Writes the given list ofActivity
s to the given file. Throws anIOException
if unable to write to the file.
edu.ncsu.csc216.wolf_scheduler.scheduler
WolfScheduler
Constants & Fields
catalog
:ArrayList
ofCourse
s that make up the course catalog.schedule
:ArrayList
ofActivity
s that make up a student’s schedule. ThisArrayList
is a subset of thecatalog
and may also containEvent
s.title
:String
representing the schedule’s title.
WolfScheduler
Constructors
WolfScheduler(String courseRecordsFileName)
: Initializesschedule
to an emptyArrayList
and setstitle
toMy Schedule
. Initializes thecatalog
ArrayList
and populates theCourse
s in the catalog from the information in thecourseRecordsFileName
. Throws anIllegalArgumentException
if the file cannot be found.
WolfScheduler
Methods
getCourseFromCatalog(String name, String section)
: Uses thename
andsection
to find aCourse
in thecatalog
. Returnsnull
if theCourse
cannot be found.addCourse(String name, String section)
: Returnstrue
if theCourse
represented by thename
andsection
are in thecatalog
and can be added to theschedule
andfalse
if theCourse
is not in thecatalog
. If there is aCourse
with the samename
already in theschedule
anIllegalArgumentException
is thrown.addEvent(String eventTitle, String eventMeetingDays, int eventStartTime, int eventEndTime, int eventWeeklyRepeat, String eventDetails)
: throws anIllegalArgumentException
if theEvent
cannot be constructed or if it is a duplicate of anEvent
already in theschedule
. Otherwise, the event is added to the end of theschedule
.removeActivity(int idx)
: Returnstrue
if theActivity
is removed from theschedule
andfalse
otherwise.IndexOutOfBoundsException
s should be handled in the method or prevented through bounds checks.resetSchedule()
: Resets theschedule
to an emptyArrayList
.getCourseCatalog()
: Returns aString[][]
(2D array) that contains acatalog
item on each row. The first column is theCourse
name
, the second is thesection
, the third is thetitle
, and the forth is the meeting string.getScheduledCourses()
: Returns aString[][]
(2D array) that contains aschedule
item on each row. The first column is theCourse
name
, the second is thesection
, the third is thetitle
, and the forth is the meeting string. Any item that an object is missing should be an empty string.getFullScheduledCourses()
: Returns aString[][]
(2D array) that contains aschedule
item on each row. The first column is theCourse
name
, the second is thesection
, the third is thetitle
, the fourth is thecredits
, the fifth is theinstructorId
, the sixth is the meeting timeString
, and the seventh is theEvent
details. Any item that an object is missing should be an empty string.setTitle(String title)
: Throws anIllegalArgumentException
if the scheduletitle
is null.getTitle()
: Returns the scheduletitle
.exportSchedule(String fileName)
: Writes theschedule
to the given file.
edu.ncsu.csc216.wolf_scheduler.ui
Guided Project 3
The implementation details for GP3 are mostly the same as GP2. This section will only focus on the differences between GP2 and GP3.
edu.ncsu.csc216.wolf_scheduler.course
Unless otherwise noted, all constants and fields are private
and all methods are public
. Constants should be static
and final
. There are no static methods in the Activity
hierarchy.
Conflict
Interface:
The Conflict
interface has a single method:
checkConflict(Activity)
: The method throws the checkedConflictException
if the possibly conflicting activity (parameter) conflicts with the current activity (this
).
ConflictException
:
The ConflictException
is a checked exception. The default message is “Schedule conflict.”
ConflictException(String message)
: Creates an exception with the given message.ConflictException()
: Creates an exception with the default message.
Activity
Updates:
Activity
implements the Conflict
interface and provides the definition of the checkConflict(Activity)
method for the Activity
hierarchy.
checkConflict(Activity)
: The method throws the checkedConflictException
if the possibly conflicting activity (parameter) conflicts with the current activity (this
).
edu.ncsu.csc216.wolf_scheduler.scheduler
Unless otherwise noted, all constants and fields are private
and all methods are public
. Constants should be static
and final
.
WolfScheduler
Updates:
The addCourse()
and addEvent()
methods are updated to use the conflict checking functionality in Activity
.
addCourse()
: if there is a conflict, theConflictException
is caught and a newIllegalArgumentException
is thrown with the appropriate message for the GUI.addEvent()
: if there is a conflict, theConflictException
is caught and a newIllegalArgumentException
is thrown with the appropriate message for the GUI.
edu.ncsu.csc216.wolf_scheduler.ui
WolfSchedulerGUI
is provided. The GUI hasn’t changed since GP2.