Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need some help please! It's a java inheritance. Create a class Person and Clerk derived from (a sub class of) Person . The Person

I need some help please! It's a java inheritance.
Create a class Person and Clerk derived from (a sub class of) Person. The Person class should have instance variables and Clerk class should have the additional information of a salary and an employmentgrade. Eg, a clerks employment grade might be (CR-1, CR-2, etc.) Both class should have the accessors, mutators and a toString() method. The toString() method in Clerk class will include a call the toString() method of the super class(Person).

A Person Has A Telephone, Address, Name, Email

The Clerk class will have an equals() method. It must override the equals method of the parentclass(Person). The equals method in the Person class to override the equals method in the Object class. We considered the difference between using == and equals() method with String objects. Any class can, and should, define its own equals method. So, what does it mean that one clerk equals another clerk? We can define this such as two Clerk objects are equal, if they have the same salary and grade. So, clerk1.equals(clerk2) will return true if their salary and grade are "equal" by the definition. You might notice that when comparing String objects, you must use the equals method defined in the String class, as opposed to the relational == operator.

The equals method MUST accept an Object as its parameter.

2) Create a .java file and use it to demonstrate following minimum:
- Your clerk Class is functioning, and the methods are correct. Create several clerks, compare them to each other using the equals method, and output clearly when one object is equal to another. Print out the objects as well
- You can output the address of a clerk object
- You can change the zip code of a clerk object and print zip code before and after change.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions