For this Scenario, just for fun, we will call the user "BillyBobJoe".
Consider he is trying to plan for his timetable. He is trying to enroll in
the course MAT257Y1
Let's say that MAT257Y1
has sections:
- LEC0101 MWF 2-3 @ MY150
- LEC0102 MWF 3-4 @ MY150
- TUT0101 T 3-5 @ MY380
- TUT0102 R 3-5 @ MY380
(Where, M = Monday, T = Tuesday, W = Wednesday, R = Thursday, F = Friday and assume all times are PM for simplicity)
-
Before BillyBobJoe even searches for a course, an Operator must first use the OperatorInterface class and set the source of data. UserInterfaces will have an instance variable
operator
that is referring to the operator. The operator can useconfigure
method to configure thedataSource
instance variable ofInterfaces
to the correct object of the DataGetter class. For the purpose of the Phase 0, this is will not be implemented. The reader automatically set toCSVReader
for this part, but for the rest of the project, we hope to use primarily WebScraper.
-
BillyBobJoe searches for the first course, which is
MAT257Y1
in Interfaces class. He will first be prompted to select the type of object that he wants to schedule. So he will enterCourse
. (See the Walk Through 2 below for scheduling aNonCourseObject
.)
-
The
Interfaces
will send this information to theInterfaceAdaptors
, which will prompt the user with questions about what they want to input. In this case, it will ask for what course BillyBobJoe wants to input, which he then entersMAT257Y1
.
-
The
InterfaceAdaptors
class then will request the data from the DataGathering class by using the instancegetData
method. The query is then sent to theDataGathering
class (whatever it is).
-
The DataGathering class (whatever it is) then collects and sorts all the course information as a
HashMap<String, Course>
where eachCourse
object only holds one section (LEC/TUT/PRA) and all the times and information relating to that one section. All the courses are then stored in aHashMap<String, Course>
, where each key is the section name and the value is theCourse
object it found. For instance, for ourMAT257Y1
course then the HashMap would look like the following:
{LEC0101: <the Course object for LEC0101>, LEC0102: <the Course object for LEC0102>, TUT0101: <the Course object for TUT0101>, TUT0102: <the Course object for TUT0102>}
The Course
object will hold all the times of the lectures of the
courses, as well as the locations of the classes at that time. For
MAT257Y1
, each course block will hold the Times and Locations as an
HashMap<ArrayList<Object>, String>
. In our example, the Course object
will hold the following in terms of timeLocation (Note, we are just being
hand-wavy here. The formatting of the strings may not be as follows, but
the idea should be the same):
HashMap<ArrayList<Object>, String> timeLocation = {
new ArrayList<Object>{"Monday", Time(14, 0, 0), Time(15, 0, 0)}: MY150,
new ArrayList<Object>{"Wednesday", Time(14, 0, 0), Time(15, 0, 0)}: MY150,
new ArrayList<Object>{"Friday", Time(14, 0, 0), Time(15, 0, 0)}: MY150
}
This is because for some courses, they occur at different locations at
different times.
-
The
InterfaceAdaptors
retrieves the HashMap from theDataGathering
class and prompts the user to select a course object by printing each the details of theCourse
. The user then types the course into the command line (at least for Phase 0) to "commit" their choice. TheInterfaceAdaptors
then sends the course object at the value of the course section that the user selected to theTimeTableManager
class. For this example,InterfaceAdaptors
will send the LEC 0101Course
object toTimeTableManager
through aschedule
method. TheSchedule
method here is Overloaded to be able to deal with bothcourse
objects andNonCourseObjects
(see Walk Through 2 for more details on this).
-
The
TimeTableManager
will look for the term of the course which has been stored in the course object. TheTimeTableManager
will then use asplit
method of theCourse
object (since Course is splittable) to get an array ofsection
objects that only stores one time and one location of a course**. In the example ofMAT257Y1
, we would have asection
array of 6 elements:- Section with time and date stored as MONDAY 2 - 3 for FALL
- Section with time and date stored as WEDNESDAY 2 - 3 for FALL
- Section with time and date stored as FRIDAY 2 - 3 for FALL
- Section with time and date stored as MONDAY 2 - 3 for WINTER
- Section with time and date stored as WEDNESDAY 2 - 3 for WINTER
- Section with time and date stored as FRIDAY 2 - 3 for WINTER
NOTE THIS IS 6 ELEMENTS BECAUSE THIS IS A YEAR COURSE. IF THIS WAS A HALF COURSE (HCourse) THERE WILL ONLY BE 3 OR SECTIONS. The
TimeTableManager
then will schedule the section in the appropriateTimeTable
using aschedule
method ofTimeTable
. This method behaves like theput
oradd
methods in HashMap and ArrayList respectively.
-
The
TimeTable
Object will then find the correct location to put the course in its storage space, which will be aHashMap<String, ArrayList<String>>
, where the keys are the days of the week and the values are theTimeTableObject
. ClassTimeTable
will then send a confirmation that it has scheduled the course properly toTimeTableManager
to inform the user that the course has been scheduled properly. If it hasn't been scheduled successfully, the TimeTable will inform theTimeTableManager
, which will inform the user that it has not been successful and that they should try again. For simplicity in Phase 0, we will assume all courses are scheduled correctly and there are no conflicts
-
Let's say the course was added successfully. BillyBobJoe will then receive a confirmation on
Interfaces
that the course has been scheduled. He then can add the next object into his timetable.
Now let's say BillyBobJoe wants to schedule a Life object. For this example, let's say he wants to schedule an hour on Wednesday to play the Theremin with the Toronto Theremin Orchestra (IDK if this is real).
-
First, he would select that he wants to add a
Life
object on the Interfaces. This is done (at least in Phase 0) by typing 'Life' into the command line when prompted.
-
This will then be sent over to
DataBaseController
to be scheduled as anNonCourseObject
. He will then be prompted to enter all the information required for the Life Object.
-
The
InterfaceAdaptors
class will then create aNonCourseObject
, which will store all the necessary information of the input, including the type of object. In this case, theNonCourseObject
will store the date, start/end time, description, term, and the name of the activity, along with the type of object, which is aLife
object
-
The
NonCourseObject
is then sent to theTimeTableManager
through theschedule
method. ONCE AGAIN, PLEASE NOTE THAT THEschedule
METHOD INTimeTableManager
IS OVERLOADED.
-
The
TimeTableManager
then will read the type of theNonCourseObject
and create the appropriateTimeTableObject
to be scheduled. In this case, it will read a Life object and create aLife
Object. The correctTimeTableObject
(in this case, a life object) will then be sent to theTimeTable
to be scheduled.
-
The
TimeTable
will then find the correct location to put the course in its storage space. Please see Part 1 for details on how this done.
-
Let's say the
Life
object was added successfully. BillyBobJoe will then receive a confirmation on Interfaces that the life has been scheduled. He then can add the next course or life object into his timetable.