Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) Create a class Person and Clerk derived from (a sub class of) Person. The Per

ID: 3840237 • Letter: 1

Question

1) 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 employment grade. Eg, a clerk’s 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 parent class(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.

Explanation / Answer

class Person{

String name;

int telephone;

String email;

String Address;


public String getName() {
   return name;
}

public void setName(String name) {
   this.name = name;
}

public int getTelephone() {
   return telephone;
}

public void setTelephone(int telephone) {
   this.telephone = telephone;
}

public String getEmail() {
   return email;
}

public void setEmail(String email) {
   this.email = email;
}

public String getAddress() {
   return Address;
}

public void setAddress(String address) {
   Address = address;
}

public Object equalsTo(Object o){

}

}

class Clerk extends Person{

double salary;

String empGrade;

public Object equalsTo(Object o){

super.equaltsTo(o);

}

}