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

Create a Person class having attributes such as name, address, birthYear, isMarr

ID: 645425 • Letter: C

Question

Create a Person class having attributes such as name, address, birthYear, isMarried and the corresponding setters and getters. Create two subclasses of the Person class: class Employed and class Student. The Employed class should have an additional static attribute isEmployed set to true and the Student class should have an additional attribute ID. Override the equals() method of the Student class to compare the values of the ID attribute. Write a Test class containing the main method in which you create instances of Person, Employed and Student classes and:

Show how the static attribute isEmployed behaves differently than an instance attribute (for example name)

Show if two Student instances are equal or not based on your equals() method.

Please see my code: I cannot get my test file to run the code and check student id.. Any help would be appreciated.

package person;

public class Person {
    private String name,address;
    private int birthyear;
    private boolean married;
  
// Constructors for name, bearthyear and address
public Person(String n, int y, String a, boolean married)
{
    this.name = n;
    this.birthyear = y;
    this.address = a;
    this.married = false;
}

/**
* @return name
*
*/
public String getName() {
return name;
}

public void setName(String n) {
this.name = n;
}
/*
/ @return address
*/
public String getAddress(){
return address;
}
/**
* @param a
*/
public void setAddress(String a){
this.address = a;
}

/**
* @return is married
*/
public boolean isMarried() {
return married;
}
/**
* @param married
*/
public void setMarried(boolean married) {
this.married = married;
}
/**
* @return the birth year of person
*/
public int getBirthyear() {
return birthyear;
}
public void setBirthyear(int y){
this.birthyear = y;
}

}

package person;

public class Student extends Person
{
    private int idNumber;
  
    public Student (String n, int y, String a, boolean married, int id)
        // Must call on partent use super
    {
        super(n,y,a,married);
        this.idNumber = id;
      
    }
        public int getIdNumber() {
        return idNumber;
        }
        public void setIdNumber(int id){
        this.idNumber = id;
    }
      
   /*
    * @Override equals method for Student Id
    */
    public boolean equals(Object c) {

        boolean status = false;

        Student student = (Student) c;

        if (getIdNumber() == student.getIdNumber() && getName().equalsIgnoreCase(student.getName())) {
            status = true;  

        }   else {

            status = false;


        }
        return status;

    }
}


public class Employee extends Person{
  
    private boolean employed;
  
    public Employee(String n, int y, String a, boolean married, int employed)
    {
       super(n,y,a,married);
       this.employed = false;
      
    }
}

Explanation / Answer

Hope it may helps you i have changed into my own style ..bit easier

class Person
{
String FirstName;//firstname
String LastName;//last name..

Person(String fName, String lName)
{
FirstName = fName;//setting firstname to person first name
LastName = lName;//setting lastname to person lastname
}

void Display()
{
System.out.println("First Name : " + FirstName);
System.out.println("Last Name : " + LastName);
}
}

class Student extends Person//here extending person to student ..Inheritance
{
int id;//this is id of student..
String level;//this is level of class
String instructor;//instructor for the class

Student(String fName, String lName, int nId, String stnd, String instr)
{
super(fName,lName);
id = nId;
level = stnd;
instructor = instr;   
}
void Display()
{
super.Display();

System.out.println("ID : " + id);
System.out.println("level : " + level);
System.out.println("Instructor : " + instructor);
}
}

class
void Display()
{
super.Display();

System.out.println("Main Subject : " + mainSubject);
System.out.println("Salary : " + salary);
System.out.println("Type : " + type);
}
}

class personstudentTask
{
public static void main(String args[])
{
Person pObj = new Person("Rayan","Miller");
Student sObj = new Student("Jacob","Smith",1,"1 - B","Roma");
  
System.out.println("Person :");
pObj.Display();
System.out.println("");
System.out.println("Student :");
sObj.Display();
System.out.println("");

}
}