CIS 636 Spring 2003                Assignment 4 – Object Oriented Programming in Java – Inheritance                           100 points

Assigned: 02/24/2003

Due: 03/03/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. The piece we are working with is a simplified hierarchy of people – including professors, and students (I called my classes Person, Professor, and Student  I still imagine that we would LATER build a Sections class that would represent a particular offering of a course, and maybe a Grade class that would keep track of a student and a grade they received for a section that they have taken.   You are to build the Person, Professor, and Student classes, and also write main program(s)  that will test out the capabilities of the classes (thoroughly).

The Person class should be able to keep track of the information common to all people involved – such as an ID number, name, address, and probably e-mail address. The functionality needed may not go much beyond providing constructors, and 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 anywhere that  is possible (e.g. though a zip code is probably a string so that leading zeros will be displayed, it is undesirable to allow an object to have a zip code that is too long, too short, or  has letters (if we are assuming use only in the US)).  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.

The Professor class should inherit ID, name, and address info from Person, and additionally should be able to keep track of the information relevant to professors – office, office phone, department, and position.  Again, the functionality needed may not go much beyond providing constructors, and 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 anywhere possible (Note that it may be impossible to catch a bad office number).  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.

The Student class should inherit ID, name, and address info from Person, and additionally should be able to keep track of the information relevant to Students – major department, year in school. For now, I recommend leaving off trying to keep track of classes taken and grades.  Again, the functionality needed may not go much beyond providing constructors, and 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 anywhere possible (we may need to let bad majors slide due to not having a list of valid majors + the extra complexity).  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(s) in such a way that will be testing out use of inheritance.   I encourage you to keep using my RedmondMsgIn and RedmondMsgOut classes, to get some simple GUI look with little code.  Note that cancels on input dialog boxes can be handled by using the Robust read methods and catching UserCancelExceptions. I don’t want to discourage anybody from doing anything fancier, but remember, that is not part of the current task.

  

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.