Python乐器
def make_sound(self):
pass
class Piano(Instrument):
def make_sound(self):
print('二胡正在演奏')
class Erhu(Instrument):
def make_sound(self):
print('钢琴正在演奏')
class Guzheng(Instrument):
def make_sound(self):
print('古筝正在演奏')
#演奏的函数
def play(instrument):
instrument.make_sound()
if __name__=='__main__':
play(Erhu())
play(Piano())
play(Guzheng())