Ejemplo n.º 1
0
def main():
    c = Child(300, 100)
    print(c.money, c.faceValue)
    c.play()
    c.eat()
    #注意:父类中方法名相同,默认调用的是在括号中排前面的父类中的方法
    c.func()
Ejemplo n.º 2
0
def main():
    c = Child(300, 100)
    print(c.money, c.faceValue)
    c.play()
    c.eat()
    #注意:父类中方法名相同,默认调用的是在class(参数括号)中派遣
    c.func()
Ejemplo n.º 3
0
def main():
    c = Child(3000, 100)
    print(c.money, c.face_value)
    c.play()
    c.eat()
    # 注意:父类中方法名相同,默认调用括号中排前面的父类的方法。
    c.func()
Ejemplo n.º 4
0
def main():
    c = Child(3000, 100)
    print(c.money, c.faceValue)
    c.play()
    c.eat()
    c.func()
Ejemplo n.º 5
0
from father import Father
from mother import Mother
from child import Child

#child继承了两个父类:Father和Mother,两个父类都有Func方法,当子类调用func方法时,默认调用的是继承括号中的第一个父类
c = Child(1000,100)
print(c.faceValue,c.money)
c.eat()
c.play()
c.func()
Ejemplo n.º 6
0
def main():
    c = Child(1111, 100)
    c.play()
    c.eat()
    #注意:父类中方法名相同,默认调用的是在括号中排前面的父类中的方法
    c.func()
Ejemplo n.º 7
0
def main():
    c = Child(30, 300)
    print(c.money, c.faceValue)

    # 注意:父类中方法相同,默认调用的是括号内排前面的
    c.func()