Question: Python Program I have 4 python files with 1 file being a superclass called Bug and the next 2 files being subclasses which are Grasshopper

Python Program
I have 4 python files with 1 file being a superclass called Bug and the next 2 files being subclasses which are Grasshopper and Spider.
The number 4 file is a Tester subclass.
The file cannot run because of errors, what am I missing in order to make these python files run?
1. Bug.py superclass
class Bug:
def __init__(self, name, num_legs, num_wings):
self.name = name
self.num_legs = num_legs
self.num_wings = num_wings
def get_name(self):
return self.name
def set_name(self, name):
self.name = name
def get_num_legs(self):
return self.num_legs
def set_num_legs(self, num_legs):
self.num_legs = num_legs
def get_num_wings(self):
return self.num_wings
def set_num_wings(self, num_wings):
self.num_wings = num_wings
def __str__(self):
return f"This is a {self.name}. It has {self.num_legs} legs and {self.num_wings} wings."
2. Grasshopper.py subclass
from Bug import Bug
class Grasshopper(Bug):
def __init__(self):
super().__init__("Grasshopper",6,4)
def __str__(self):
message = super(Grasshopper, self).__str__()
message +="
Grasshoppers are common in the Everglades and play a vital role in the ecosystem."
return message
3. Spider.py subclass
from Bug import Bug
class Spider(Bug):
def __init__(self):
super(Spider, self).__init__("Spider",8,0)
def __str__(self):
message = super(Spider, self).__str__()
message +="
The golden orb weaver has a mild venom that is not poisonous to humans."
return message
4. Tester.py subclass
from Bug import Bug
from Grasshopper import Grasshopper
from Spider import Spider
class Tester:
def __init__(self):
self.bug = Bug("Millipede",1000,0)
self.spider = Spider()
self.grasshopper = Grasshopper()
#Step 10. Print out the message statement for all bugs
def print_info(self):
print(self.bug)
print(self.spider)
print(self.grasshopper)
tester = Tester()
tester.print_info()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!