Answered step by step
Verified Expert Solution
Link Copied!

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 Person(String pname,String paddress, String phNum, String pemail)
{
name = pname ;
address=paddress;
phone=phivum;
email=pemail;
]
(/ tostring() method to return the name
public String toString()
t.
return getClass().getName()+""+name;
]
}
??? 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 =1;
final int sophomore =2;
final int junior=3;
final int senior =4;
String status="freshman";
??? Constructor with arguments
public Student(String name, String address, String phonenumber,
String email, int Status)
{
super (name, address, phonenumber, email);
if (Status ==1)
{
status = "freshman";
}.
if (Status ==2
f
status = "sophomore";
}.
if (Status ==3)
I.
status = "junior";
}.
if Status ==4
i
status = "Senior";
}.
status = "Student";
1
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):
office=off;
}.
salary=sal;
public String toString()
{
return (super.toString ()+n+ office +""+ salary):
3
image text in transcribed

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 1 Lnai 9284

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Carlos Soares ,Joao Gama ,Alipio Jorge

1st Edition

3319235273, 978-3319235271

More Books

Students also viewed these Databases questions