Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Note: Mod ified code ( add ed new code ) highlight ( bold ) w ith grey color background. / / Design a class named
Note: Mod ified code add ed new code highlight bold w ith grey color background.
Design a class named Person
Person java
public class Person
person has a name, address, phone number, and email address.
String name;
String address;
String phone;
String email;
Constructor with arguments
public PersonString pname,String paddress, String phNum, String pemail
name pname ;
addresspaddress;
phonephivum;
emailpemail;
tostring method to return the name
public String toString
t
return getClassgetNamename;
Student java
public class Student extends Person
A student has a class status
freshman sophomore, junior, or senior
Define the status as a constant.
final int freshman ;
final int sophomore ;
final int junior;
final int senior ;
String status"freshman";
Constructor with arguments
public StudentString name, String address, String phonenumber,
String email, int Status
super name address, phonenumber, email;
if Status
status "freshman";
if Status
f
status "sophomore";
if Status
I.
status "junior";
if Status
i
status "Senior";
status "Student";
public String toString
i
return super, toString status;
Emplovee.java
public class Employee extends Person
An employee has an office, salary, and date hired.
String office;
double salary;
java.util.Date dateHired;
Constructor with arguments
public Employee String name, String address, String phonenumber,
String email, String off, double sal
super name address, phonenumber, email:
officeoff;
salarysal;
public String toString
return supertoString office salary:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started