#!/usr/bin/env python
# Author:liujun
class People(object):
def __init__(self,name,age):
self.name = name
self.age = age
def eat(self):
print("%s is eating ...."% self.name)
def talk(self):
print("%s is sleeping ..."% self.name)
def sleep(self):
print("%s is sleeping...."%self.name)
class Man(People):
def __init__(self,name,age,money): # Overwrite the constructor
#Version 1
#People.__init__(self,name,age)
#Version 2
super(Man,self).__init__(name,age)
self.money = money
print("You have %d money when you are borned..."% self.money)
def piao(self): # This is a new method in Man
print("%s is piao .... 20s .... done"% self.name)
def sleep(self): # overwrite the method in sleep
People.sleep(self)
print("man is sleeping......")
class Woman(People):
def getBirth(self):
print("%s is born a baby......"% self.name)
m1 = Man("Liujun",28,100)
m1.eat()
m1.piao()
m1.sleep()
w1 = Woman("ChenRongHua",26)
w1.getBirth()