Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4 :Unit test Tests constructor Stringlnstrument ( ' Guitar ' , 'Gibson', 2 0 0 2 , 1 2 0 0 , 6 , 1
:Unit test
Tests constructor StringlnstrumentGuitar 'Gibson', False sets mystringinstrument.numstrings
Your test produced
no output.
:Unit test
Tests constructor StringlnstrumentGuitar 'Gibson', False sets mystringinstrument.numfrets
Your test produced
no output.
:Unit test
Tests constructor StringInstrumentViola 'Yamaha', True sets mystringinstrument.isbowed True
Your test produced
no output
LAB: Instrument information
derived classes
Given the base class Instrument, define a derived class StringInstrument for string instruments with a constructor that initializes the attributes of the Instrument class as well as new attributes of the following types
integer to store the number of strings
integer to store the number of frets
boolean to store whether the instrument is bowed
Ex
If the input is:
Drums
Zildjian
Guitar
Gibson
False
the output is:
Instrument Information:
Name: Drums
Manufacturer: Zildjian
Year built:
Cost:
Instrument Information:
Name: Guitar
Manufacturer: Gibson
Year built:
Cost:
Number of strings:
Number of frets:
Is bowed: False
Here is my code and the error that I am recieving: class Instrument:
def initself name, manufacturer, yearbuilt, cost:
self.name name
self.manufacturer manufacturer
self.yearbuilt yearbuilt
self.cost cost
def printinfoself:
printfInstrument Information:"
printfName: selfname
printfManufacturer: selfmanufacturer
printfYear built: selfyearbuilt
printfCost: selfcost
class StringInstrumentInstrument:
def initself name, manufacturer, yearbuilt, cost, numstrings, numfrets, isbowed:
superinitname manufacturer, yearbuilt, cost
self.numstrings numstrings
self.numfrets numfrets
self.isbowed isbowed
def printinfoself:
superprintinfo
printfNumber of strings: selfnumstrings
printfNumber of frets: selfnumfrets
printfIs bowed: selfisbowed
# Read input
instrumentname input
instrumentmanufacturer input
instrumentyearbuilt intinput
instrumentcost intinput
stringinstrumentname input
stringinstrumentmanufacturer input
stringinstrumentyearbuilt intinput
stringinstrumentcost intinput
stringinstrumentnumstrings intinput
stringinstrumentnumfrets intinput
stringinstrumentisbowed input "True"
# Create Instrument object
instrument Instrumentinstrumentname, instrumentmanufacturer, instrumentyearbuilt, instrumentcost
# Create StringInstrument object
stringinstrument StringInstrumentstringinstrumentname, stringinstrumentmanufacturer, stringinstrumentyearbuilt, stringinstrumentcost stringinstrumentnumstrings, stringinstrumentnumfrets, stringinstrumentisbowed
# Print information
instrument.printinfo
print
stringinstrument.printinfo
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