Create a class Clerk derived from a sub class of Person The

Create a class Clerk derived from (a sub class of) Person. The new class should have instance variables that record the additional information of a salary and an employment grade. Eg, a clerk’s employment grade might be (CR-1, CR-2, etc.) Add the accessors and mutators and a toString() method. The toString() method will call the toString() method of the super class. The Clerk class will have an equals() method. It must override the equals method of the parent class. Change 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 define its own equals method. So, what does it mean that one clerk equals another clerk? We can define this however we please. Let\'s say that 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 your definition. The equals method MUST accept an Object as its parameter. 2) Create a Java application and use it to demonstrate: - 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.

Solution

I have written the code for the clerk class. Some of the variables in the code has a user defined type like address which is not known. The class clerk is derived from the Person class and I have added the accessor and the mutators in the code.

public class Contact {

        private static int contactsCreated=0;

private String name;

private Address address;

private Telephone telephoneNumber;

private String emailAddress;

public static int getContactsCreated(){

        return contactsCreated;

}

       @Override

public String toString() {

        return \"NAME : \"+name+\" | ADDRESS : \"+address+\" | PHONE : \"+telephoneNumber+\" | EMAIL : \"+emailAddress+\" \";

}

public Contact(String name, Address address, Telephone telephoneNumber, String emailAddress) {

        super();

        this.name = name;

        this.address = address;

        this.telephoneNumber = telephoneNumber;

        this.emailAddress = emailAddress;

        contactsCreated++;

}

public String getName() {

        return name;

}

public void setName(String name) {

        this.name = name;

}

public Address getAddress() {

        return address;

}

public void setAddress(Address address) {

        this.address = address;

}

public Telephone getTelephoneNumber() {

        return telephoneNumber;

}

public void setTelephoneNumber(Telephone telephoneNumber) {

        this.telephoneNumber = telephoneNumber;

}

public String getEmailAddress() {

        return emailAddress;

}

public void setEmailAddress(String emailAddress) {

        this.emailAddress = emailAddress;

}

public static void setContactsCreated(int contactsCreated) {

        Contact.contactsCreated = contactsCreated;

}

}

Create a class Clerk derived from (a sub class of) Person. The new class should have instance variables that record the additional information of a salary and a
Create a class Clerk derived from (a sub class of) Person. The new class should have instance variables that record the additional information of a salary and a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site