为了账号安全,请及时绑定邮箱和手机立即绑定

继承的两个父类的参数不一致,子类应该怎么写

class Person(object):

    def __init__(self, name, gender):

        self.name = name

        self.gender = gender

class Skillmixin(object):

    def __init__(self,skill):

        self.skill=skill

class Teacher(Person):

    def __init__(self, name, gender, course):

        super(Teacher, self).__init__(name, gender)

        self.course = course

class FootballMixin(Skillmixin):

    def __init__(self,skill,sex):

        super(FootballMixin,self).__init__(skill)

        self.sex=sex

class Football_teacter(Teacher,FootballMixin):

    def __init__(self,name,gender,course,skill,sex,color):

        super(Football_teacter,self).__init__(name, gender, course)

#        super(Teacher,self).__init__(skill,sex)


        self.color=color

s = Football_teacter('Bob', 'golor', '数学','ccc','足球','hot')

print(s.color)

print(s.name)

print(s.gender)

print(s.course)

print(s.skill)

print(s.sex)


正在回答

1 回答

class P(object):

    def __init__(self,name):

        self.name = name


class Skill(object):

    def __init__(self,skill):

        self.skill = skill

  

class F(Skill):

    def __init__(self,skill):

        super(F,self).__init__(skill)

        #self.skill = 'football'


class B(Skill):

    def __init__(self,skill):

        super(B,self).__init__(skill)

        #self.skill = 'basketball'

        

class S(P, B):

    def __init__(self,name,skill):

        P.__init__(self,name)

        B.__init__(self,skill)

        print ('{}打{}'.format(self.name,self.skill))

    

class T(P, F):

    def __init__(self,name,skill):

        P.__init__(self,name)

        F.__init__(self,skill)

        print ('{}打{}'.format(self.name,self.skill))


        

S('student','basketball')

T('teacher','football')


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

继承的两个父类的参数不一致,子类应该怎么写

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信