Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

For the base class Person example provided in the Unit 3 Revisiting the Employee Class Program tutorial, if we need to add a subclass for

For the base class Person example provided in the Unit 3 Revisiting the Employee Class Program tutorial, if we need to add a subclass for Volunteers who have a host employee and are assigned to a project, what code segment could implement this subclass and create an instance of it called volunteer_1?
class Volunteer:
def __init__(self,fname,lname,title,host,project):
super().__init__(fname,lname,title)
self.host = host
self.project = project
def get_host(self):
return "Host: "+ str(self.host)
def set_host(self,newhost):
self.host = newhost
def get_project(self):
return "Project: "+ str(self.project)
def set_project(self, project):
self.project = project
volunteer_1= Volunteer('John','Doe','Volunteer','Jane Doe','Project_X')
class Volunteer:
def __init__(self,fname,lname,title,host,project):
super().__init__(fname,lname,title,project)
self.host = host
self.project = project
def get_host(self):
return "Host: "+ str(host)
def set_host(self,newhost):
self.host = newhost
def get_project(self):
return "Project: "+ str(project)
def set_project(self, project):
self.project = project
volunteer_1= Volunteer('John','Doe','Volunteer','Jane Doe','Project_X')
class Volunteer(Person):
def __init__(self,fname,lname,title,host,project):
super().__init__(fname,lname,title, project)
self.host = host
self.project = project
def get_host(self):
return "Host: "+ str(self.host)
def set_host(self,newhost):
self.host = newhost
def get_project(self):
return "Project: "+ str(self.project)
def set_project(self, project):
self.project = project
volunteer_1= Volunteer('John','Doe','Volunteer','Jane Doe','Project_X')
class Volunteer(Person):
def __init__(self,fname,lname,title,host,project):
super().__init__(fname,lname,title)
self.host = host
self.project = project
def get_host(self):
return "Host: "+ str(self.host)
def set_host(self,newhost):
self.host = newhost
def get_project(self):
return "Project: "+ str(self.project)
def set_project(self, project):
self.project = project
volunteer_1= Volunteer('John','Doe','Volunteer','Jane Doe','Project_X')

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions