Question: Specific Requirements We will begin the development of a simple University registration system that keeps track of students, instructors, and courses. We will have students

Specific Requirements

We will begin the development of a simple University registration system that keeps track of students, instructors, and courses. We will have students and instructors that share many common traits such as names and social security numbers. By using the concept of inheritance, we can separate out the common entities that both Students and Instructors have and place these common elements in a separate Person class. Then we can inherit from this Person class and avoid writing the same code several times. Correspondingly, in our classes, if we have code that appears several times, we can abstract it out and place it in a separate method and have the method called when we need this particular functionality. In Instructor and Student, we will abstract out the common code in the two constructors (for each class) and place it in a method called setAttributes. This way we have the code in a single place and, if we find errors, we only have to change it in one place to fix it.

In this project you will write five classes. The first will be a class that represents a person. The second will be a class that represents a college student. The third will an instructor. The fourth class will simulate a class membership list. The fifth will be a test class to verify exhaustively the correctness of the other four classes; you should test at least once for each method.

Notice that both the Student Class and the Instructor Class inherit from the Person Class. A student is a special Person. An Instructor is also a special person, but is a different kind of special person than is a Student. It is important that you take advantage of the functionality of the super-class when you write these subclasses. The primary advantage of inheritance is to be able to reuse code.

Person Class

Instance Fields

// You need not use these names, but you must use these types

String firstName

String lastName

String ssn

Constructors

// Default - Sets last name, first name and ssn to "unknown"

Person()

// Three string parameters are first name, last name and ssn

// Be certain that the parameters are in that order

Person ( String, String, String )

Methods

// Sets the person's first name, last name and ssn

// Be certain that the parameters are in that order

setAttributes( String, String, String )

// Returns a String containing the persons first name

getFirstName()

// Returns a String containing the persons last name

getLastName()

// Returns a String containing the persons ssn

getSSN()

// This method is a member of the Comparable interface.

// Briefly, it compares the parameter Object to this object

// and decides whether this object is less than, equal to or greater than

// the parameter Object. It then returns an integer indicating the

// outcome of that comparison. The possible values for the return value

// are a negative value, zero or a positive value.

//

// There are several things to consider here. First of all we need a policy.

// This method is going to be used to assist in getting persons into

// alphabetical order, so the policy will be that this method will

// look at both last name and first name when comparing persons. It

// will not look at ssn. The first names need be

// compared only if the last names are the same. Remember that case

// matters. If ASCII codes are used to compare Strings, all uppercase

// characters come before all lowercase characters.

// ASCII --- 'A' = 65, 'Z' = 90, 'a' = 97

// (ex. Zac comes before alice alphabetically)

//

// One option would be to convert all names to the same case for

// purposes of comparison. In this project we will simply assume that

// all names are supplied correctly (always dangerous) and compare them

// as is. (Let "Zac" come before "al" )

// Finally, remember to indicate that Person implements the

// comparable interface in your class declaration statement and

// be sure that your parameter type is Object and not Student

compareTo( Object )

// Returns a boolean indicating whether the parameter Object is equal to

// this object

// Note: the policy will be that two persons with the same ssn are duplicates

// even if the names are different

equals( Object )

//...etc

Inheritance

Here are a few reminders about inheritance. All methods and instance fields of the superclass are inherited by the subclass. Private instance fields in the superclass can be accessed only through accessors. If a method in the superclass does not perform exact functionality required by the subclass, it can be overridden in the subclass (remember the signatures must match). New methods may be written for the subclass that do not appear in the superclass. Finally, constructors are not inherited, but the constructors in the superclass can be called explicitly from the subclass. Be careful about accidentally shadowing variables in the superclass by re-declaring them in the subclass.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!