Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON Add the missing code so that the following actions are completed: DrummerFactory is a subclass of MusicianFactory A DrummerFactory creates a Musician with a

PYTHON

Add the missing code so that the following actions are completed:

DrummerFactory is a subclass of MusicianFactory

A DrummerFactory creates a Musician with a Drum

A Drum makes a Bang! noise when it is played

A Musician plays their instrument in playInstrument. This should return the sound of the instrument played.

If a Musician starts playing music for a second time, it should throw an Exception with the message Already playing!

Here's the code

class MusicianFactory: # Creates a Musician # returns the created Musician def createMusician(self): return None

class Instrument: # Plays the Instrument # returns the instrument's sound def play(self): return None

class DrummerFactory: pass;

class Drum: pass;

class Musician: def __init__(self, instrument): raise Exception('Waiting to be implemented!')

def playInstrument(self): raise Exception('Waiting to be implemented!')

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_2

Step: 3

blur-text-image_step3

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