StudentBasketball的構(gòu)造函數(shù)改怎么寫?
# Enter a code
#encoding=utf-8
class Person(object):
? ? def __init__(name,gender):
? ? ? ? self.name=name
? ? ? ? self.gender=gender
? ? ? ??
? ? def who(self):
? ? ? ? return 'I'm a person,my name is %s' %s self.name
? ? ? ??
class Student(Person):
? ? def __init__(self,name,gender,score):
? ? ? ? super(Student,self).__init__(name,gender)
? ? ? ? self.score=score
? ? ? ??
? ? def who(self):
? ? ? ? return 'I'm a student,my score is %s' % self.score
? ? ? ??
class Teacher(Person):
? ? def __init__(self,name,gender,course):
? ? ? ? super(Teacher,self).__init__(name,gender)
? ? ? ? self.course=course
? ? ? ??
? ? def who(self):
? ? ? ? return 'I'm a Teacher,my course is %s' % self.course
? ? ? ??
? ? ? ??
class SkillMixin(objetc):
? ? def __init__(self,ball):
? ? ? ? self.ball=ball
? ? ? ??
? ? def skill(self):
? ? ? ? return 'I can play %s' % self.ball
? ? ? ??
class BasketballMixin(SkillMixin):
? ? def __init__(self,ball,basketball):
? ? ? ? super(BasketballMixin,self).__init__(ball)
? ? ? ? self.basketball=basketball
? ? ? ??
? ? def skill(self):
? ? ? ? return 'I can play %s' % self.basketball
? ? ? ??
class FootballMixin(SkillMixin):
? ? def __init__(self,ball,football):
? ? ? ? super(FootballMixin,self).__init__(ball)
? ? ? ? self.football=football
? ? ? ??
? ? def skill(self):
? ? ? ? return 'I can play %s' % self.football
? ? ? ??
class StudentBasketball(Student,BasketballMixin):
? ? def __init__(self,name,gender,score,skill):? ? ? ? #對(duì)嗎
? ? ? ? super(StudentBasketball,self).__init__()? ? ? ? #不會(huì)寫了
? ? ? ??
2021-10-26