Skip to content

Instantly share code, notes, and snippets.

@broschke
Last active March 12, 2019 15:51
Show Gist options
  • Save broschke/92a80614ec7abc6081fa688243b779b4 to your computer and use it in GitHub Desktop.
Save broschke/92a80614ec7abc6081fa688243b779b4 to your computer and use it in GitHub Desktop.
class Musician(object):
def __init__(self, sounds):
self.sounds = sounds
def solo(self, length):
for i in range(length):
print(self.sounds[i % len(self.sounds)], end=" ")
print()
class Bassist(Musician): # The Musician class is the parent of the Bassist class
def __init__(self):
# Call the __init__ method of the parent class
super().__init__(["Twang", "Thrumb", "Bling"])
class Guitarist(Musician):
def __init__(self):
# Call the __init__ method of the parent class
super().__init__(["Boink", "Bow", "Boom"])
def tune(self):
print("Be with you in a moment")
print("Twoning, sproing, splang")
class Drummer(Musician):
def __init__(self):
# Call the __init__ method of the parent class
super().__init__(["Bang", "Thump", "Crash"])
def count(self):
for i in range(1,5):
print(i)
def combust(self):
print("I'm on fire")
class Band(Musician):
def __init__(self):
self.members = []
def hire(self):
members.append(self)
def fire(self):
members.remove(self)
#not sure how to the do the solo after count to 4
nigel = Drummer()
nigel.solo(6)
print(nigel.sounds)
nigel.count()
nigel.combust()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment