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.
~/$ 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 > quitA Part 1 solution is a program that processes the following two user commands:
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.import java.io.*;
~/$ java Proj01 sectionsCS.txt > sections IT360 IT360 2002 MF2,R12 MI222,MI392 IT360 4001 MF4,R34 MI295,MI392 > quitA 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!
~/$ 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 > quitA 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.
Error! Section not found! is printed.
Important! You may assume that no schedule ever contains more than 10 sections, which makes your schedule class a bit easier to write.
~/$ 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 quitFor 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:
Weeks (i.e. if you are busy a given period
in either week, you are busy in the merged week).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: |
|
~/$ 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 > quitA Part 5 solution extends the Part 3 solution by adding a command to show the week-grid for the current schedule:
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.
~/$ 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 > quitA Part 5 solution extends the Part 3 solution by adding a command that lists sections that fit into the current schedule:
README
with your name and alpha code, which step you are submitting
for, and any issues you know your program has.
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.
submit -c=IC211 -p=proj01 README *.javaThe test cases are labeled by part, so if you submit a Part 3 solution, you want it to pass all tests labeled part1, part2 and part3, but you expect it to fail all the tests labeled part4 and part5.
/** * Each public method, constructor and class must be preceeded with a comment of this form */