CIS 636 Spring 2003
Assignment 5 – Object
Oriented Programming in Java – Bringing Together Some Pieces
100 points
Assigned: 03/03/2003
Due: 03/17/2003 at the start of class
You may work
individually or in pairs for this assignment. But all work must be the work of
the person/people whose name is on the code! If working in pairs, the
individual contributions should be relatively equal. One possibility is to work
together tonight, then finish separately (to avoid communication difficulties).
Main Assignment:
We are
building more pieces of an university registration program. Now, we want to
create a Section class that will represent particular offering of Courses, and
handle the connection between Sections and Students. I have modeled this situation in one way. I see a class in
between Students and Sections, that would keep track of the student/Section
association, along with the student’s grade in that section once it is assigned
(I call this class Enrollment, but I almost called it TranscriptItem). You may
not decide to model it the same way; there are trade-offs! My way of modeling it makes this assignment
harder, but should make a later assignment easier! Whatever you build, again,
also write main program(s) that will
test out the capabilities of the classes (thoroughly).
The way I envision the
situation, there is a Section class that should be able to keep track of,
section ID (CRN in La Salle lingo), the Course the section is an offering of,
the section number (e.g. 01, BA), the semester, year, and time it was offered,
the building and room it was held in, the maximum enrollment allowed, the
professor that is teaching the class, and a list of enrollments of students
signed up for the class. I believe that
the Course and Professor should be in a “containment” relationship with the
Sections class – that they should be a instance variable that is “part-of” a
section. This works ok because the instance variables are references to the
actual objects. Some people may see section as extending Course instead. Besides basic getters and setters and
constructors, and overridden object methods, the Section class should be able
to report the number of spaces taken by students and the number of spaces
remaining, and be able to sign up, and delete students from the section, and
perhaps to delete all students from the section (canceled section).
I will present my rationale for
having a separate Enrollment class, you may avoid this in some way. I wanted to
store the grade with the student and section that they took. I could have made
“parallel arrays” inside of Section, so that the Nth element of the students
array went with the Nth element of the grades array, but that may make
accessing info more difficult and more risky.
By having Student, Section, and grade info together, I have a complete
cross reference, so if I have an enrollment I can get to any info I need. This
was extra work, but it gives me flexibility of access later.
I also added to the Student
class, a list of enrollments for the student. This is redundant info, and
redundant info can be dangerous – there is a risk of inconsistency. The
trade-off again is flexibility. Having the list of enrollments as part of
Sections facilitates registration, class rolls. Having the list of enrollments
as part of Student facilitates printing transcripts, calculating GPA, etc. In
modeling this, one thing one might ask is what questions will we be trying
answer / task will we be trying to accomplish most often?
Above, my modeling mentioned
“lists”. These can be implemented using arrays or fancier data structures. I
implemented using Vectors which are flexible size arrays (almost). This avoids
writing a lot of code to re-size arrays. Sun’s reference at http://java.sun.com/j2se/1.4/docs/api/ is helpful if you want to pick these up.
This assignment is a fairly big chunk of code if you go for
full flexibility. You may want to keep
testing simple, rather than anticipating the final registration system. Note
also that it is not due until 3/17.
Hand in:
Miscellaneous:
·
MAKE SURE YOUR
PROGRAM WORKS! (i.e. more than just removing compile errors). Your program
needs to be able to handle any valid inputs, and catch invalid values.
·
Make sure that your
main(s) demonstrate that your class methods work.
·
Put YOUR NAME, and
e-mail address in comments at the beginning of the program.
·
Remember: Indentation, meaningful variable names, and
meaningful comments. Weaknesses in any of these could result in points off. You MUST include comments that explain your
program in order to get full credit.