CIS 636 Fall 2002 Assignment 3 – Object Oriented Programming in Java – Creating a Class 100 points
Assigned: 02/10/2003
Due: 02/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 one piece of an university registration program. The piece we are
starting with is a simplified class to keep track of info about a particular
course (I called my version of the class Course). I imagine that we would LATER
build a Sections class that would represent a particular offering of a course,
and a Student class that would keep track of a student and sections that they
have registered for. You are to build
the Course class, and also write a main program (probably part of the same
class) that will test out the capabilities of the class (thoroughly).
The Course class should be able to keep track of the
department, course number, title, number of credits, and a set of prerequisites
for the course. It should be able to report whether a given course is a
prerequisite for the current (invoking) course. It should allow adding and
deleting a prerequisite for the course.
It should provide all necessary accessors – inspectors and mutators
(‘getters’ and ‘setters’), so that data can all be declared as private. Mutators should protect against bad data
getting into objects (e.g. negative credits).
Some flexibility should be provided in object creation by providing
different constructors. The class
should support versions of equals and toString appropriate to the class.
I encourage you to write your main in such a way that will
be testing out future use for course scheduling (e.g. create an array of Courses and work with that). I encourage you to keep using my
RedmondMsgIn and RedmondMsgOut classes, to get simple GUI look with little
code. I don’t want to discourage anybody from doing anything fancier, but
remember, that is not part of the current task. Note that cancels on input
dialog boxes will not be fully handled until we cover exceptions.
You are free to use more flexible data structures than
arrays for the set of prerequisites, but make sure you don’t bite off too much
learning for you to chew.
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 of the
correct type (for now (until we cover exceptions), we won’t catch invalid
values that are the wrong type (e.g. letters where numbers are
needed)).
·
Make sure that your
main demonstrates 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.