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 thesectionString, which is a value of 3MAX_NAME_LENGTH: constant containing the maximum length of thenameString, which is a value of 6MIN_NAME_LENGTH: constant containing the minimum length of thenameString, 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:Stringcontaining theCourse’s nametitle:Stringcontaining theCourse’s titlesection:Stringcontaining theCourse’s sectioncredits:intcontaining theCourse’s credit hoursinstructorId:Stringcontaining theCourse’s instructor idmeetingDays:Stringcontaining theCourse’s meeting daysstartTime:intcontaining theCourse’s start timeendTime:intcontaining 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 anIllegalArgumentExceptionif 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 anIllegalArgumentExceptionif provided an invalid value. The values ofstartTimeandendTimeare 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 anIllegalArgumentExceptionif the parameter is null or less than theMIN_NAME_LENGTHor greater than theMAX_NAME_LENGTH.setTitle(): throws anIllegalArgumentExceptionif the parameter is null or an emptyString.setSection(): throws anIllegalArgumentExceptionif the parameter is null or has a length not equal toSECTION_LENGTH.setCredits(): throws anIllegalArgumentExceptionif the parameter is less thanMIN_CREDITSor greater thanMAX_CREDITSsetInstructorId(): throws anIllegalArgumentExceptionif the parameter is null or an emptyString.setMeetingDays(): throws anIllegalArgumentExceptionif 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 theStringsetCourseTime(): throws anIllegalArgumentExceptionif thestartTimeorendTimeis not between 0 andUPPER_TIMEor 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 aStringrepresentation of theCoursemeeting 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 ofCoursefields 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 anArrayListof validCourses read from the given file name. The method throws aFileNotFoundExceptionif the given file doesn’t exist.readCourse(String line): Returns aCourseobject created by parsing the line of text. This is aprivatehelper 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 ofCourses to the given file. Throws anIOExceptionif unable to write to the file.
edu.ncsu.csc216.wolf_scheduler.scheduler
WolfScheduler Constants & Fields
catalog:ArrayListofCourses that make up the course catalog.schedule:ArrayListofCourses that make up a student’s schedule. ThisArrayListis a subset of thecatalog.title:Stringrepresenting the schedule’s title.
WolfScheduler Constructors
WolfScheduler(String courseRecordsFileName): Initializesscheduleto an emptyArrayListand setstitletoMy Schedule. Initializes thecatalogArrayListand populates theCourses in the catalog from the information in thecourseRecordsFileName. Throws anIllegalArgumentExceptionif the file cannot be found.
WolfScheduler Methods
getCourseFromCatalog(String name, String section): Uses thenameandsectionto find aCoursein thecatalog. Returnsnullif theCoursecannot be found.addCourse(String name, String section): Returnstrueif theCourserepresented by thenameandsectionare in thecatalogand can be added to thescheduleandfalseif theCourseis not in thecatalog. If there is aCoursewith the samenamealready in thescheduleanIllegalArgumentExceptionis thrown.removeCourse(String name, String section): Returnstrueif theCourseis removed from thescheduleandfalseotherwise.resetSchedule(): Resets thescheduleto an emptyArrayList.getCourseCatalog(): Returns aString[][](2D array) that contains acatalogitem on each row. The first column is theCoursename, the second is thesection, and the third is thetitle.getScheduledCourses(): Returns aString[][](2D array) that contains ascheduleitem on each row. The first column is theCoursename, the second is thesection, and the third is thetitle.getFullScheduledCourses(): Returns aString[][](2D array) that contains ascheduleitem on each row. The first column is theCoursename, 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 anIllegalArgumentExceptionif the scheduletitleis null.getTitle(): Returns the scheduletitle.exportSchedule(String fileName): Writes thescheduleto the given file.
edu.ncsu.csc216.wolf_scheduler.ui
Guided Project 2
Guided Project 2 will walk you through the addition of Events 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:Stringcontaining theCourse’s titlemeetingDays:Stringcontaining theCourse’s meeting daysstartTime:intcontaining theCourse’s start timeendTime:intcontaining theCourse’s end time
Activity Constructors
Activity(String title, String meetingDays, int startTime, int endTime): Sets the fields to the given values or throws anIllegalArgumentExceptionif 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 anIllegalArgumentExceptionif the parameter is null or an emptyString.setMeetingDays(): sets themeetingDaysfield.setActivityTime(): throws anIllegalArgumentExceptionif thestartTimeorendTimeis not between 0 andUPPER_TIMEor 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 aStringrepresentation 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 ofStrings.getLongDisplayArray(): Abstract method that returns an array ofStrings.isDuplicate(): Abstract method that returns true if the givenActivityis a duplicate of this object.
Course Constants & Fields
SECTION_LENGTH: constant containing the length of thesectionString, which is a value of 3MAX_NAME_LENGTH: constant containing the maximum length of thenameString, which is a value of 6MIN_NAME_LENGTH: constant containing the minimum length of thenameString, 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:Stringcontaining theCourse’s namesection:Stringcontaining theCourse’s sectioncredits:intcontaining theCourse’s credit hoursinstructorId:Stringcontaining 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 anIllegalArgumentExceptionif 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 anIllegalArgumentExceptionif provided an invalid value. The values ofstartTimeandendTimeare 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 anIllegalArgumentExceptionif the parameter is null or less than theMIN_NAME_LENGTHor greater than theMAX_NAME_LENGTH.setSection(): throws anIllegalArgumentExceptionif the parameter is null or has a length not equal toSECTION_LENGTH.setCredits(): throws anIllegalArgumentExceptionif the parameter is less thanMIN_CREDITSor greater thanMAX_CREDITSsetInstructorId(): throws anIllegalArgumentExceptionif the parameter is null or an emptyString.setMeetingDays(): overridesActivity’ssetMeetingDays(). Throws anIllegalArgumentExceptionif 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 theStringhashCode()andequals(): Use Eclipse to generatehashCode()andequals()on all fields.toString(): Returns a comma separated list ofCoursefields in the format expected in [UC1, S1] and [UC3, S2].getShortDisplayArray(): Returns an array ofStrings containingname,section,title, and meeting stringgetLongDisplayArray(): Returns an array ofStrings containingname,section,title,credits,instructorId, meeting string, and empty string.isDuplicate(): Returns true if the givenActivityis a duplicate of theCoursebyname.
Event Constants & Fields
weeklyRepeat: int that describes how many weeks between eventseventDetails:Stringcontaining 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 anIllegalArgumentExceptionif 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 anIllegalArgumentExceptionif the parameter is less than one or greater than 4.setEventDetails(): throws anIllegalArgumentExceptionif the parameter is null.setMeetingDays(): overridesActivity’ssetMeetingDays(). Throws anIllegalArgumentExceptionif 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 ofEventfields in the format expected in expected in [UC3, S2].getShortDisplayArray(): Returns an array ofStrings containing empty string, empty string,title, and meeting stringgetLongDisplayArray(): Returns an array ofStrings containing empty string, empty string,title, empty string, empty string, meeting string, and event details.isDuplicate(): Returns true if the givenActivityis a duplicate of theEventbytitle.
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 anArrayListof validCourses read from the given file name. The method throws aFileNotFoundExceptionif the given file doesn’t exist.readCourse(String line): Returns aCourseobject created by parsing the line of text. This is aprivatehelper 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 ofActivitys to the given file. Throws anIOExceptionif unable to write to the file.
edu.ncsu.csc216.wolf_scheduler.scheduler
WolfScheduler Constants & Fields
catalog:ArrayListofCourses that make up the course catalog.schedule:ArrayListofActivitys that make up a student’s schedule. ThisArrayListis a subset of thecatalogand may also containEvents.title:Stringrepresenting the schedule’s title.
WolfScheduler Constructors
WolfScheduler(String courseRecordsFileName): Initializesscheduleto an emptyArrayListand setstitletoMy Schedule. Initializes thecatalogArrayListand populates theCourses in the catalog from the information in thecourseRecordsFileName. Throws anIllegalArgumentExceptionif the file cannot be found.
WolfScheduler Methods
getCourseFromCatalog(String name, String section): Uses thenameandsectionto find aCoursein thecatalog. Returnsnullif theCoursecannot be found.addCourse(String name, String section): Returnstrueif theCourserepresented by thenameandsectionare in thecatalogand can be added to thescheduleandfalseif theCourseis not in thecatalog. If there is aCoursewith the samenamealready in thescheduleanIllegalArgumentExceptionis thrown.addEvent(String eventTitle, String eventMeetingDays, int eventStartTime, int eventEndTime, int eventWeeklyRepeat, String eventDetails): throws anIllegalArgumentExceptionif theEventcannot be constructed or if it is a duplicate of anEventalready in theschedule. Otherwise, the event is added to the end of theschedule.removeActivity(int idx): Returnstrueif theActivityis removed from thescheduleandfalseotherwise.IndexOutOfBoundsExceptions should be handled in the method or prevented through bounds checks.resetSchedule(): Resets thescheduleto an emptyArrayList.getCourseCatalog(): Returns aString[][](2D array) that contains acatalogitem on each row. The first column is theCoursename, the second is thesection, the third is thetitle, and the forth is the meeting string.getScheduledCourses(): Returns aString[][](2D array) that contains ascheduleitem on each row. The first column is theCoursename, 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 ascheduleitem on each row. The first column is theCoursename, 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 theEventdetails. Any item that an object is missing should be an empty string.setTitle(String title): Throws anIllegalArgumentExceptionif the scheduletitleis null.getTitle(): Returns the scheduletitle.exportSchedule(String fileName): Writes thescheduleto 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 checkedConflictExceptionif 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 checkedConflictExceptionif 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, theConflictExceptionis caught and a newIllegalArgumentExceptionis thrown with the appropriate message for the GUI.addEvent(): if there is a conflict, theConflictExceptionis caught and a newIllegalArgumentExceptionis thrown with the appropriate message for the GUI.
edu.ncsu.csc216.wolf_scheduler.ui
WolfSchedulerGUI is provided. The GUI hasn’t changed since GP2.