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

Hi can do this code Java Design a class named Person and its two subclasses name

ID: 3775690 • Letter: H

Question

Hi

can do this code Java

Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, and date-hired. Define a class named My Date that contains the fields year, month, and day A faculty member has office hours and a rank. A staff member has a title. Override the toString method in each class to display the class name and the person's name. Draw the UML diagram for the classes. Implement the classes. Write a test program that creates a Person, Student, Employee, Faculty', and Staff, and invokes their toString () methods.

Explanation / Answer

Person.java

public class Person {
   //Declaring variables
private String name,address,email_address;
private String phone_number;

//Zero Argument Constructor
public Person() {
   super();
}

//Parameterized constructor.
public Person(String name, String address, String email_address,
       String phone_number) {
   super();
   this.name = name;
   this.address = address;
   this.email_address = email_address;
   this.phone_number = phone_number;
}

//Setters and getters
public String getName() {
   return name;
}
public void setName(String name) {
   this.name = name;
}
public String getAddress() {
   return address;
}
public void setAddress(String address) {
   this.address = address;
}
public String getEmail_address() {
   return email_address;
}
public void setEmail_address(String email_address) {
   this.email_address = email_address;
}
public String getPhone_number() {
   return phone_number;
}
public void setPhone_number(String phone_number) {
   this.phone_number = phone_number;
}

//toString() method displays the contents of the object.
@Override
public String toString() {
   return "Person [name=" + name + ", address=" + address + ", email_address="
           + email_address + ", phone_number=" + phone_number + "]";
}


}

____________________

Student.java

public class Student extends Person{
private int status;

public static int freshman = 1;

public static int sophomore =2;

public static int junior =3;

public static int senior =4;

public Student(){

}

public Student(int status){

this.status = status;

}

public Student(String name, String address, String phone, String email, int status){

super(name, address, email,phone);

this.status = status;

}

public String toString(){
   System.out.println(super.toString());
return "Student " + this.status;

}

}

___________________

Employee.java

public class Employee extends Person {
   //Declaring variables
private String office;
private double salary;
private MyDate date_hired;

//Zero Argument Constructor
public Employee() {
   super();
}

//Parameterized constructor.
public Employee(String name, String address, String email_address,
       String phone_number,String office, double salary, MyDate date_hired) {
   super(name,address,email_address,phone_number);
   this.office = office;
   this.salary = salary;
   this.date_hired = date_hired;
}

//Setters and getters
public String getOffice() {
   return office;
}
public void setOffice(String office) {
   this.office = office;
}
public double getSalary() {
   return salary;
}
public void setSalary(double salary) {
   this.salary = salary;
}
public MyDate getDate_hired() {
   return date_hired;
}
public void setDate_hired(MyDate date_hired) {
   this.date_hired = date_hired;
}
//toString() method displays the contents of the object.
@Override
public String toString() {
   System.out.println(super.toString());
   return "Employee [office=" + office + ", salary=" + salary
           + ", date_hired=" + date_hired + "]";
}


}

_______________________

Faculty.java

public class Faculty extends Employee {
   //Declaring variables
private int office_hours;
private String rank;

//Zero Argument Constructor
public Faculty() {
   super();
}

//Parameterized constructor.
public Faculty(String name, String address, String email_address,
       String phone_number,String office, double salary, MyDate date_hired,int office_hours, String rank) {
   super(name,address,email_address,phone_number,office,salary,date_hired);
   this.office_hours = office_hours;
   this.rank = rank;
}

//Setters and getters
public int getOffice_hours() {
   return office_hours;
}


public void setOffice_hours(int office_hours) {
   this.office_hours = office_hours;
}


public String getRank() {
   return rank;
}


public void setRank(String rank) {
   this.rank = rank;
}

//toString() method displays the contents of the object.
@Override
public String toString() {
   System.out.println(super.toString());
   return "Faculty [office_hours=" + office_hours + ", rank=" + rank + "]";
}


}

_____________________

Staff.java

public class Staff extends Employee {
   //Declaring variables
private String title;

//Zero Argument Constructor
public Staff() {
   super();
}

//Parameterized constructor.
public Staff(String name, String address, String email_address,
       String phone_number,String office, double salary, MyDate date_hired,String title) {
   super(name,address,email_address,phone_number,office,salary,date_hired);
   this.title = title;
}

//Setters and getters
public String getTitle() {
   return title;
}

public void setTitle(String title) {
   this.title = title;
}

//toString() method displays the contents of the object.
@Override
public String toString() {
   System.out.println(super.toString());
   return "Staff [title=" + title + "]";
}

}

_____________________

MyDate.java

import java.util.Calendar;

public class MyDate {
   //Declaring variables
private int year,month,day;

//Zero Argument Constructor
public MyDate() {
   super();
   Calendar now = Calendar.getInstance(); // Gets the current date and time
   this.year=now.get(Calendar.YEAR);
   this.month=now.get(Calendar.MONTH);
   this.day=now.get(Calendar.DAY_OF_MONTH);
}

//Parameterized constructor.
public MyDate(int year, int month, int day) {
   super();
   this.year = year;
   this.month = month;
   this.day = day;
}

//Setters and getters
public int getYear() {
   return year;
}

public void setYear(int year) {
   this.year = year;
}

public int getMonth() {
   return month;
}

public void setMonth(int month) {
   this.month = month;
}

public int getDay() {
   return day;
}

public void setDay(int day) {
   this.day = day;
}

//toString() method displays the contents of the object.
@Override
public String toString() {
   return +day +"-"+month+"-"+year;
}

}

______________________

Test.java

public class Test {

   public static void main(String[] args) {

       Person person[]={
               new Person("Kane","101 Church Street","kaneatmail.com","123-123-1234"),
               new Student("Mary Jane", "44 That Street","123-123-1234","mjatmail.com",3),
               new Employee("Gary Rug", "500 Over There Street","gratmail.com", "123-123-1236","Microsoft" ,85000, new MyDate(2010,6,24)),
               new Faculty("Jose Bee", "867 Hay Street","jbatmail.com", "123-123-1237","Accenture",92000 ,new MyDate(2010,6,24),8, "Professor"),
               new Staff("Sue Joe", "6 Here Street","sjatmail.com", "123-123-1238","Oracle",97000,new MyDate(2012,4,22), "Janitor" )
               };
      
       for(int i=0;i<person.length;i++)
       {
           System.out.println(person[i].toString());
       }
      
      
   }

}

________________

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote