Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For the base public class Person example provided in the Unit 3 Revisiting the Employee Class Program tutorial, what if you need to add a
For the base public class Person example provided in the Unit Revisiting the Employee Class Program tutorial, what if you need to add a subclass for Visitors who have a host employee and are visiting a specific building?
What code segment could implement this subpublic class and create an instance of it called visitor
public class Visitor extends Person
private String host;
private String areaVisiting;
public VisitorString firstName,String lastName,String jobTitle,String host, String areaVisiting
super;
this.host host;
this.areaVisiting areaVisiting;
public String getHost
return "Host this.host;
public void setHostString newhost
this.host newhost;
public String getArea
return "Area Visiting this.areavisiting;
public void setArea String areaVisiting
this.areaVisiting areaVisiting;
Visitor visitor new VisitorJohn"Doe","Visitor","Jane Doe","Main Building";
public class Visitor extends Person
private String host;
private String areaVisiting;
public VisitorString firstName,String lastName,String jobTitle,String host, String areaVisiting
superfirstNamelastName,jobTitle,host,areaVisiting;
this.host host;
this.areaVisiting areaVisiting;
public String getHost
return "Host this.host;
public void setHostString newhost
this.host newhost;
public String getArea
return "Area Visiting this.areavisiting;
public void setArea String areaVisiting
this.areaVisiting areaVisiting;
Visitor visitor new VisitorJohn"Doe","Visitor","Jane Doe","Main Building";
public class Visitor extends Person
private String host;
private String areaVisiting;
public VisitorString firstName,String lastName,String jobTitle,String host, String areaVisiting
superfirstNamelastName,jobTitle;
this.host host;
this.areaVisiting areaVisiting;
public String getHost
return "Host this.host;
public void setHostString newhost
this.host newhost;
public String getArea
return "Area Visiting this.areaVisiting;
public void setArea String areaVisiting
this.areaVisiting areaVisiting;
Visitor visitor new VisitorJohn"Doe","Visitor","Jane Doe","Main Building";
public class Visitor
private String host;
private String areaVisiting;
public VisitorString firstName,String lastName,String jobTitle,String host, String areaVisiting
superfirstNamelastName,jobTitle;
this.host host;
this.areaVisiting areaVisiting;
public String getHost
return "Host this.host;
public void setHostString newhost
this.host newhost;
public String getArea
return "Area Visiting this.areavisiting;
public void setArea String areaVisiting
this.areaVisiting areaVisiting;
Visitor visitor new VisitorJohn"Doe","Visitor","Jane Doe","Main Building";
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