Assignment 2 — CSC207H: Summer 2009
     July 2009      
Su Mo Tu We Th Fr Sa
          1  2  3  4
 5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   
            
        

Due Tuesday, July 7th, 2009 at 10:00am sharp.

Check out the assignment 2 material from your repository. In your repository you should find a directory named assignments containing a sub-directory named a2. There you should find a file named index.html that has the same contents as what you are reading right now.

In assignment 1, you wrote an application that pulls course data from webpages; in assignment 2, you will be writing an application to present possible section combinations to a user.

Storing course information

When you ask an undergraduate student "What courses are you taking this semester?", they rattle off a list of course identifiers. They don't tell you the lecture times, they don't tell you which tutorials they've signed up for, they don't tell you anything except course ids. To them (and to you, up until you did A1), a course was collectively a course code, a section code, and lists of lecture sections, tutorial sections, and practical sections.

Write a Course class to model a course as described in the previous paragraph. Remember that there is a scheduling component to this assignment, and that every course you want to schedule may need a lecture, a tutorial, and a practical; all of them will need to be scheduled. Keep this in mind when deciding what classes to create. You might, for example, want to write another class to store information about a meeting section and its list of times, and keep track of lists of the three kinds of meeting sections in your Course class. This will make the scheduling code easier to write.

For this assignment, we've made parsing easier to level the playing-field. Instead of reading from an HTML document, read from a text file given as the first argument to your program. Each line of the text file will be formatted as follows:

            COURSE TIME MEETING_SECTION LOCATION
        

Each field (i.e., "COURSE", "TIME", and "MEETING_SECTION") will be separated by exactly one space. The time will be a one hour slot; the day will be given as a single letter (M, T, W, R, or F) and the time immediately follows as a two-digit 24 hour start time. This format does not have any means of representing classes that start at half past. The times for a meeting section are the aggregates of all the times that match the meeting section and course code. The file will only contain courses for a single term.

The input file may contain blank lines. Lines beginning with a hash sign (#) are to be ignored. The order of lines in the file does not matter. That is, your program should work even if lines are swapped at random. The following is an example input file:

            ############################################
            # BCH210 -- Biochemistry I
            ############################################
            # Lectures
            BCH210 M14 L0101 PBB150
            BCH210 M15 L0101 PBB150
            BCH210 W14 L0101 PBB150
            BCH210 W15 L0101 PBB150
            BCH210 F14 L0101 PBB150
            BCH210 F15 L0101 PBB150


            ############################################
            # CHM138 -- Intro to Organic Chemistry I
            ############################################
            # Lectures
            CHM138 T09 L0101 BA1160
            CHM138 T10 L0101 BA1160
            CHM138 T11 L0101 BA1160

            # Practicals
            CHM138 T13 P0201 TBA
            CHM138 T14 P0201 TBA
            CHM138 T15 P0201 TBA
            
            CHM138 W13 P0301 TBA
            CHM138 W14 P0301 TBA
            CHM138 W15 P0301 TBA

            # Tutorials
            CHM138 T14 T0101 TBA
            CHM138 R14 T0101 TBA
            CHM138 W14 T0201 TBA
            CHM138 R14 T0201 TBA
            
            
            ############################################
            # CSC108 -- Intro to Comp Prog
            ############################################
            # Lectures
            CSC108 R18 L5101 BA1200
            CSC108 R19 L5101 BA1200
            CSC108 R20 L5101 BA1200
            
            # Tutorials
            CSC108 W16 T0101 TBA
            CSC108 W17 T0101 TBA

            CSC108 R14 T0201 TBA
            CSC108 R15 T0201 TBA


            ############################################
            # CSC207 -- Software Design
            ############################################
            # Lectures
            CSC207 T18 L5101 BA1200
            CSC207 T19 L5101 BA1200
            CSC207 T20 L5101 TBA
        

Terminology

For this section of the assignment ("Producing schedules"), let a "course scheduling" refer to the combination of a lecture section, practical section, and tutorial section. If a course does not have all of these, the course scheduling will not have the corresponding component. E.g., a course scheduling for CHM138 has a lecture section, tutorial section, and a practical section while a course scheduling for CSC108 has only a lecture section and tutorial section.

Let a "schedule" refer to a collection of course schedulings for between 1 to 8 courses; a "non-conflicting schedule" is one for which no course schedulings in a schedule contain sections that occur at the same time and day.

Producing non-conflicting schedules

Combination: m choose n

Before worrying about conflicts, it is probably a good idea to focus on producing different every combination of courses and sections you can. Let's build our way up. Consider the following list of items:

            [1, 2, 3, 4, 5]
        

For some n less than or equal to five, how can we write a program to produce every combination of items? For n = 2, we should get

            [1, 2]
            [1, 3]
            [1, 4]
            [1, 5]
            [2, 3]
            [2, 4]
            [2, 5]
            [3, 4]
            [3, 5]
            [4, 5]
        

Adding sub-lists

Now, suppose we had the following list of lists of lists:

            [
                [
                    ['1-a-1', '1-a-2'],
                    ['1-b-1'],
                    ['1-c-1']
                ],
                [
                    ['2-a-1', '2-a-2'],
                    ['2-b-1', '2-b-2', '2-b-3']
                ]
            ]
        

We want to pick some subset of the lists at the outer-most level and pick one item from each of the inner-most lists for those lists. Suppose we wanted to pick all of the lists at the outer-most level. Then we'd need to pick a 1-a-x, 1-b-x, 1-c-x, 2-a-x, and 2-b-x.

Here, the first digit corresponds to a different course. The letter in the middle corresponds to a lecture/practical/tutorial (of which, if you choose a course, you must take one of each). The last digit corresponds to an individual lecture/practical/tutorial section.

Removing conflicts

Now that you are able to generate every possible schedule, you need some method of identifying conflicts. Depending on how you've designed your Course class will have a big influence on the difficulty of this task. Once you can do this and remove all those schedules, what you're left with is a non-conflicting schedule!

A GUI

Finish your program by adding in some sort of way for a user to specify the desired course-load (between 1 and 8 courses, inclusive). Then, your program should display a non-conflicting timetable (if one exists) from the set of courses in the text file specified as a command line argument to your program.

To receive full marks, we should be able to start your program with

            java a2.Timetabler filename.txt
        

You will probably want to look into writing a Swing GUI to manage this program. A JTextField will likely be useful. You might also want to use JButtons, JTextAreas, and JTables.

Marking

We will be marking your program manually using a marking scheme inspired by the University of Toronto Grading Regulations.

You can earn up to 80% for having a working program with a simple GUI. You can earn more marks for having a "slick" GUI with lots of features; the more the better. An A+ will be given only for a well-designed, stylistically beautiful, fully-functional program with an "easy-to-use" GUI that displays results in a readable, useable form.

Having an incomplete program with a beautiful GUI will earn you less marks than a completely working program with a basic GUI. You will only earn the extra marks if your program is completely functional. You can get part marks for being submitting a program that implements one of the hints in "Producing non-conflicting schedules". If your program does this, it should still start when run as described in "A GUI", but instead of running a fully-working program, it should give instructions on how to start the hint implementation.

You will, of course, be marked on both correctness and style. Include full Javadoc, including @return, @param, and @throws tags. Use classes and helper methods and name them well. Avoid duplicate code. Follow the Java coding standards — especially naming conventions. Be consistent in your brace placement, indent your code, and all that good stuff. Run Source->Format regularly to get a good start.

Javadoc should have complete sentences with proper punctuation and grammar, follow conventions of good technical writing (brevity, clarity, simplicity), and should be complete. For methods, the first sentence is used in the method summary section, and the rest appears in the method details. You should at least have @param, @throws, and @return tags in addition to the method description. Marks may be taken off for problems found in Javadoc content.

You will be marked on the design of your program: make your code modular, use classes and helper methods when appropriate, and so on.