Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA I need to make this program work and I cannot get it. Advise please... The senario is as follows... (The Person, Student, Employee, Faculty,

JAVA

I need to make this program work and I cannot get it. Advise please... The senario is as follows...

(The Person, Student, Employee, Faculty, and Staff classes) 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. Use the MyDate class defined in Programming Exercise 10.14 to create an object for date hired. 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 persons name.

Draw the UML diagram for the classes and implement them. Write a test pro- gram that creates a Person, Student, Employee, Faculty, and Staff, and invokes their toString() method

public class Exercise01_02

{

public String pname;

public String paddress;

public int ppno;

public String pemail;

public Person (String name, String address, int phonenumber, String email)

{

pname = name;

paddress = address;

ppno = phonenumber;

pemail = email;

}

public String toString()

{

public getClass().getName()+" "+pname;

}

}

public class Student extends Person

{

public String SStatus;

public Student (String name, String address, int phonenumber, String email, String Status)

{

super(name, address, phonenumber, email);

SStatus = Status;

}

public String toString()

{

return getClass().getName()+ " "+pname;

}

}

public class Employee extends Person

{

private String Eoffice;

private double ESalary;

public Employee (String name, String address, int phonenumber, String email)

{

super (name, address, phonenumber, email);

}

public String toString()

{

return getClass().getName()+ " "+pname;

}

}

public class Faculty extends Employee

{

private int OfficeHours;

int rank;

public Faculty (String name, String email, int phonenumber, String email, int OfficeHours, int rank)

{

super (name, address, phonenumber, email);

this.OfficeHours = OfficeHours;

this.rank = rank;

}

public String toString()

{

return getClass().getName() + " "+pname;

}

}

public class Staff extends Employee

{

private String Title;

public Staff(String name, String address, int phonenumber, String email)

{

super(name, address, phonenumber, email);

}

public String toString()

{

return getClass().getName() + " " + pname;

}

}

public class MyDate

{

int year;

int month;

int day;

}

class TestClass

{

public static void main (String[] args)

{

Person p= new Person ("George" , "USA", 990123, "george@gm@il.com");

Person s=new Student ("Peter", "UK", 9876, "peter@y@hoo.com", "Senior");

Person e= new Employee ("William", "South", 23451, "william@awg.in");

Person f= new Faculty ("Gaddy", "USA", 992323, "gaddy@qa.com", 200, 45);

Person st= new Staff ("Reena", "Nuzvid", 22111, "reena@y@hoo.in");

System.out.println(p.toString());

System.out.println(s.toString());

System.out.println(e.toString());

System.out.println(f.toString());

System.out.println(st.toString());

}

}

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

Step: 3

blur-text-image

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

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions