CPSC 233: Assignment 3 (Worth 5%)
Due Wednesday October 13
New concepts to be applied for the assignment
- Dynamic memory allocation using references and class constructors
- Arrays of references
- Using code in predefined Java classes (String, Character)
Writing a program to manage a course list
For this assignment you are to write a
program that will allow a student to track the number of courses that he or she
has taken. The courses will be stored in an array and the program can
track information for up to 100 courses.
Grading for working submission
Basic submission ('C' grade):
Functional
requirements
-
Initializing the list to some starting default values.
-
Displaying the list in a presentable form e.g., empty list elements should
not be displayed, lists that are very long (say over 5 elements in size)
should not be displayed all at once but instead the user should have the
ability to see only a portion of the list at a time and then the program will
wait for a response from the user (e.g., asking the person to hit return) before displaying any other elements.
-
A menu of options is displayed onscreen.
Although for this grade level not all options will be working, at the
very least the user should be able to display the list and to quit the program.
Design requirements: You need to implement four classes: Driver, CommandProcessor,
CourseTracker, Course:
-
Class Driver: The starting point of execution in the program
(contains the main method).
-
Class CommandProcessor: The
purpose of this class to provide an interface to the user: it shows the
available menu options as prompting the user for his or her selection.
Based on the user's selection, different methods of class CourseTracker will then be invoked
by the command processor.
-
Class CourseTracker: It performs
the basic list management functions: initializing and displaying the list
onscreen, adding new elements, removing or editing existing elements.
Information about the list of courses will be stored in an array of
references. This
array will be an attribute
of this class.
-
Class Course: Tracks the pertinent
information about a course: 1) The four character course code (e.g., CPSC)
2) The three digit course number (e.g., 233) 3) The year that course was taken (4
digit integer) 4) The grade received ('A', 'B', 'C', 'D' or 'F').
Extra features (completing all three can yield a grade of 'A+'):
-
Searching for a course (increase of 1 letter 'step'):
The user will be prompted to enter in a course code and course number and the
program will search the list for a match. If a match is found then the
program will display all details about the course (all four fields). If
no match was found then the program will indicate that the search was
unsuccessful because the course was not in the list. If the list is empty no search will performed and an error
message will be displayed instead. The user should be able to enter in
the course code in upper or lower case characters and program will convert all
lower case values to upper case equivalents. The program will
check that the course code consists of exactly four characters and will
continue prompting the user if it is not. The course number must consist
of exactly three digits (from 100 to 999 inclusive). If the user
enters in a course number outside of this range the program will again
continue prompting him or her to enter a proper value. An option
to cancel the search process should be provided in both cases.
Cancelling the search will
bring the user back to the main menu.
-
Adding a new course (increase of 2 letter 'steps'):
The user will be prompted to enter in the
information for a new course. This course will be inserted into the list
according to a chronological ordering. For example, there are currently
two courses in the list: the first
course was taken in 1997 2) the second was taken in 2001. The user
then wants to add a new course which she took in 1996. The program will have to
shift the existing elements in order to make room for the new element.
The second element is shifted into the third position while the first
element is shifted into the second position. The new element is then
inserted into the first position of the list. If the list already at the
maximum possible size no addition will performed and an error message will be
displayed to the user. The program will check that the values for the
course code and course number are valid as it did with searches.
Although the program doesn't directly check that the year was valid, entering a
negative value will allow the user to cancel the process of adding a new
course. Finally the program should check that the letter grade entered
is in the range of 'A' - 'F', excluding the 'E' character but including upper
or lower case input. Lower case values for the course code or letter
grade will be converted by the program into the corresponding upper case value
before the new course is added to the list.
-
Editing an existing course (increase of 2 letter 'steps'):
The user will be prompted to enter in a course
code and course number and then the program will search the list for a match.
If a match is found the program will then prompt the user to enter new
information for the four fields of the class. If no match
was found then the program will indicate that the search was unsuccessful
because the course was not in the list. If the
list is empty no search will performed and instead an error message will be displayed. The program will check for the validity of the input in the
same fashion as the addition of a new course.
-
Removing an existing course (increase of 2 letter 'steps'):
The user will be prompted to enter in a
course code and course number and the program will search the list for a
match. If a match is found then the program will delete that entry.
If the element to be deleted is not the last element then the elements that
follow the element to be deleted must be shifted up. For example if the
list consists of three elements and the user wants to delete the first
element, then the
second element is shifted into the first position and the third element is
shifted into the second position. At this point your program should now
treat the list as if it only had two elements. In this example no
third element will be displayed. If no match was found then the
program will indicate that the deletion was unsuccessful because the course
was not in the list. If the list is
empty no search will performed and an error message will be displayed to the
user. The program must check for the validity of the course code and
course number as was the case with the search function above.
Grading: Non-working submissions
D submissions:
The student has invested considerable time
and effort into the assignment, the program does not fulfill any of the above
requirements but it does compile.
D- submissions:
The student has invested considerable time
and effort into the assignment, the program does not fulfill any of the above
requirements and it does not compile.
Other submission requirements
In addition to having fulfill the generic
assignment requirements the requirements specific to this assignment include:
1. Good coding style and documentation:
They will play a role in determining your final
grade for this assignment. Your grade can be reduced by a letter step
or more (e.g., 'A' to 'A-' for poor programming style such as employing poor naming
conventions for identifiers, insufficient documentation, the use of global
variables or by not assigning the proper operations and attributes to classes).
2. Include a README file in your submission: For this assignment
your README file must indicate what functions you have completed as well as the
grade level that you are aiming for.
This will allow your marker to quickly determine what he or she must look for
and speed up the marking process. For example:
e.g., I completed the "C" level requirements plus:
- The search function (+1)
- The remove function (+2)
Total estimated grade = 2.0 + 3 steps = 3.0
3. Assignments (source code and the README file) must be electronically
submitted via submit.
In addition a paper print out of the source code must be handed into the
assignment drop box for the lab that you are registered in (located on the
second floor of the Math Sciences building). Electronically submitting the
assignment allows your marker to run the code in order to quickly determine what
features were implemented. Providing a paper printout makes it easier for
your marker to read and flip through your source code.