Python乐器
2023-06-14 08:25
views:
974
source:
596
class Instrument():
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())
Disclaimer: The above articles are added by users themselves and are only for typing and communication purposes. They do not represent the views of this website, and this website does not assume any legal responsibility. This statement is hereby made! If there is any infringement of your rights, please contact us promptly to delete it.