Executive Summary

Due dates: Part 1 - 2359 Tuesday 6 Feb, Full submission - 2359 Friday 16 Feb.
You will be implementing a simple applictation to keep track of an academic schedule here at USNA. The User can list sections for a given course, add a section to their schedule, and view their week in the usual grid format. If you scroll down to "Part 5", you can see an example run of the program.
Note: The primary goal is for you to show good Object Oriented Programming practices — specifically Encapsulation and Information Hiding — in your solution!

Honor: The course policy and the instructions it references, most pertinently COMPSCIDEPTINST 1531.1C, spell out what kinds of assistance are permissable for programming projects. The instructor can give explicit permission for things that would otherwise not be allowed. For this project, you have explicit permission
  1. to get help from both Spring 2024 IC211 instructors and MGSP leaders (any assistance must be documented though), and
  2. to use general purpose Java resources online (though such use must be documented). Resources that might specifically address this project, say looking through code of programs that track schedules, deal with days of the week, or print information in grids, are not allowed.
Put together the instructions referenced in the course policy and the explicit permissions above, and what you get is summarized as:

Note: Though not an honor issue, if your use of outside resources of any kind results in code that your instructor believes you don't completely understand, you won't get credit for it and the burden will be on you to prove that you really do understand it.

Part 1[up to 25pts]: Listing sections

~/$ java Proj01 sections11.txt
> sections IC211
IC211 1001 T12,WF1 MI316
IC211 3002 T34,WF3 MI302,MI202
IC211 5004 T56,WF5 MI302,MI222
> asfd
Unkown command: asfd
> sections IC221
IC221 2004 MW2,R12 MI302
IC221 4002 MW4,R34 MI316
IC221 4003 MW4,R34 MI302
IC221 6001 MW6,R56 MI316
> sections XY001
> quit
A Part 1 solution is a program that processes the following two user commands: The file containing section data is given as a command-line argument when running the program. The program must print the following usage message if no command-line argument is given:
usage: java Proj01 <sectionsfile>
For this Part you may use the file sections11.txt, that only contains 11 sections. You may hard-code the assumption that there are exactly 11 sections to be read in - for this part only!

Important 1: The output must separate items on a line by a single space, as shown in the example. Note that the input file uses tabs rather than spaces.
Important 2: Good object oriented design dicates that you create a class to represent a section.
Important 3: For all of this project, if the user inputs an invalid command, output an error message in the format shown in the example on the right. A non-existent section is not an error, you just will print nothing.

Hint: Recall from Lab 2 that you can create a Scanner that reads from a file with the following code:

Scanner sc = null;
try { sc = new Scanner(new FileReader(fname)); } 
catch(IOException e) { e.printStackTrace(); System.exit(1); }
... where fname is a String containing the filename.
Note: you will need: import java.io.*;

Part 2[up to 50pts]: Listing sections, arbitrary-length files of section data

~/$ java Proj01 sectionsCS.txt
> sections IT360
IT360 2002 MF2,R12 MI222,MI392
IT360 4001 MF4,R34 MI295,MI392
> quit
A Part 2 solution is exactly the same as a Part 1 solution, except that you may not assume that the file of sections has only 11 entries — it may have an arbitrary number of entries. (Try sectionsCS.txt, for example.) This is going to require some kind of linked list code! I would encourage you to go look back at the WordRead class from Lab02, or the Queue class from Lab04. Remember: linked-lists are the same regardless of what type of data you store in them!

Part 3[up to 70pts]: Adding sections, showing schedules

~/$ java Proj01 sectionsCS.txt
> sections IC211
IC211 1001 T12,WF1 MI316
IC211 3002 T34,WF3 MI302,MI202
IC211 5004 T56,WF5 MI302,MI222
> add IC211 3001
Error! Section not found!
> add IC211 3002
> sections IC221
IC221 2004 MW2,R12 MI302
IC221 4002 MW4,R34 MI316
IC221 4003 MW4,R34 MI302
IC221 6001 MW6,R56 MI316
> add IC221 6001   
> show
IC211 3002 T34,WF3 MI302,MI202
IC221 6001 MW6,R56 MI316
> quit
A Part 3 solution extends the Part 2 solution by adding two new commands that allow you to create and show a schedule consisting of multiple sections. Note: Good object oriented design demands that you create a separate class for schedules, even though at this point you'll only need to instantiate a single schedule.

Important! You may assume that no schedule ever contains more than 10 sections, which makes your schedule class a bit easier to write.

Part 4[up to 90pts]: A temporary detour into weeks

~/$ java Week
  M T W R F
1          
2          
3          
4          
5          
6          
MWF3
  M T W R F
1          
2          
3 x   x   x
4          
5          
6          
TR6,F56
  M T W R F
1          
2          
3 x   x   x
4          
5         x
6   x   x x
quit 
For Part 4 you are going to create a new class, called Week, that represents the usual grid of periods 1-6 and days MTWRF, and simply remembers whether a period is free or not. Your Week class must be able to:
  1. construct empty weeks
  2. construct weeks based on a standard USNA meeting-time pattern, e.g. MWF3,T34 or TR9, and
  3. merge two Weeks (i.e. if you are busy a given period in either week, you are busy in the merged week).
Running Week should give a simple testing program that starts with an empty week and continually reads in meeting patterns which are then merged with the current week. The grid gets printed out at each step, as shown in the sample run to the right, with an X marking every period that's "busy".

Important: Meeting time patterns can be a pain in the neck, so I'll explain them here, and give you some code to help. A meeting time pattern is a comma-separated (no spaces!) list of elements, each element consisting of one or more characters representing days {M,T,W,R,F}, followed by a period, which is one of {1,2,3,4,5,6,12,34,56,8,9,10}. So, for example, a common meeting time pattern is MWF4,R34. Sometimes you get something like MF2,W1,T12. To help you deal with this, I'm providing the ic211 package with class DrBrown, (install&use directions in note below, see also documentation) which provides the static method

public static String[] explode(String pat)
... that takes a String with a meeting time pattern, and returns the pattern "exploded" into its atomic meetings: a string of length two consisting of a day and a single period 1-6. So, for example, exploding "MWF2,R12" gives the array
{"M2","W2","F2","R1","R2"}
This should make your life a lot easier with the Week class. Develop week incrementally: first get the constructors and the printing working. Test thorougly, then get the merging working, and test that thoroughly.
Note:
  • to use the DrBrown class in your code, include the statement import ic211.*; and call as DrBrown.explode(...)
  • to install the package (which you only need to do once, of course), make sure you are in your project 1 directory and do:
    curl https://faculty.cs.usna.edu/~wcbrown/courses/S24IC211/proj/p01/ic211.tgz | tar xz
    If this was successful, the command ls ic211 will list some .class files.

Part 5[up to 100pts]: showing the week-grid for the schedule

~/$ java Proj01 sectionsCS.txt
> add IC211	5004
> add IC220	6002        
> add IT360	2002
> week
  M T W R F
1       x  
2 x     x x
3          
4          
5   x x   x
6 x x x   x
> sections IC221
IC221 2004 MW2,R12 MI302
IC221 4002 MW4,R34 MI316
IC221 4003 MW4,R34 MI302
IC221 6001 MW6,R56 MI316
> add IC221 4003
> show
IC211 5004 T56,WF5 MI302,MI222
IC220 6002 MWF6 MI202
IT360 2002 MF2,R12 MI222,MI392
IC221 4003 MW4,R34 MI302
> week
  M T W R F
1       x  
2 x     x x
3       x  
4 x   x x  
5   x x   x
6 x x x   x
> quit
A Part 5 solution extends the Part 3 solution by adding a command to show the week-grid for the current schedule: Of course you'll make heavy use of the Week class you created in the previous step to do this. Be sure to make good OOP decisions about where to put the pieces of code that provide this new functionality.

Part 6[Extra Credit 10pts]: listing sections that fit

~/$ java Proj01 sectionsCS.txt
>  add IC211 3002
>  add IC221 2004
>  fit IC220
IC220 4003 MWF4 MI202
IC220 5004 MWF5 MI202
IC220 6002 MWF6 MI202
>  add IC220 6002
>  week
  M T W R F
1       x  
2 x   x x  
3   x x   x
4   x      
5          
6 x   x   x
>  fit IT430
IT430 5003 MR5,T56 MI201
>  add IT430 5003
>  fit SI110
SI110 4001 MF4,R34 MI200
SI110 4002 MF4,R34 MI203
SI110 4003 MF4,R34 MI206
SI110 4004 MF4,R34 MI220
>  add SI110 4001
>  fit any
IT486D 1001 T12,WF1 MI300
SI204 1001 MWF1,T12 MI392
SI221 2001 MF1,T12 MI202,MI303
SI335 3001 MWF1 MI222
>  quit 
A Part 5 solution extends the Part 3 solution by adding a command that lists sections that fit into the current schedule: Important: a section "fits" the current schedule if the course is not already in the schedule, and no period M-F,1-6, that covered or partially covered by the new section is covered or partially covered in the current schedule. I.e. if the "week grid" versions of the schedule and the section have an x in the same spot, they don't fit!

When to submit

What to submit

Your electronic submission must include:
  1. all .java file required to compile and run your program - including the ones you were given in the assignment
    Note: Please make sure that your name and alpha code appear in evey single file .java file.
  2. a file named README with your name and alpha code, which step you are submitting for, and any issues you know your program has.
Your paper submission must inlcude:
  1. A completed copy of this coversheet on paper.

How to submit

The paper portions of your submission should be stapled together and slid under your prof's door. For electronic submission, use submit as described below. Submitting more than you need to submit is always OK. Just be sure that all the files needed to compile and run your project are there. You may submit files at any time, but only the last submission will be used for grading.
Note: the submit system will give you feedback about whether or not you passed various tests and, if you fail, it we'll give you a comparison between what the output should have been, and what your output was. So please use that to your advantage!

How projects are graded / how to maximize your points

Things to keep in mind to receive full marks:
  1. Submit all required items (as described above) on time.
  2. Make sure your output matches the example output in all ways, and make sure your code passes all the tests run by the submit system.
  3. Use good object-oriented design! The means adhering to the principles of ecapsulation and data/information hiding. This, in turn, means making good decisions about what to turn into classes.
  4. Practice good Java Style. This means proper indentation, use of whitespace within lines of code, logical organization of chunks of code, proper naming of classes, methods, fields and constants in accordance with Java conventions. This means good commenting! At a minimum: your name & alpha in every file, and descriptive comments immediatedly preceeding each public method, constructor and class using the Java convention that they look like this:
    /**
     * Each public method, constructor and class must be preceeded with a comment of this form
     */
    	  
Most important: Look at the the grading sheet!