#-*-coding:utf-8-*-
__author__ = "logan.xu"
class People:
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 talking..." %self.name)
def sleep(self):
print("%s is sleeping..." %self.name)
class Man(People): #子类继承父类people
#在子类中重构方法,先从子类中访问。值先传到子类man中,在到父类找
#在子类中添加woman子类没有的参数money
#然后在继承父类的参数,并定义子类man的money参数
def __init__(self,name,age,money):
People.__init__(self,name,age)
self.money = money
print("%s出生带金钥匙%smoney"%(self.name,self.money))
def piao(self):
print("%s is piaoing....20s...done"%self.name)
#重构父类的方法
def sleep(self):
People.sleep(self) #调用父类的方法把self传进去
print("man is sleeping")
#添加子类woman
class Woman(People):
def get_birth(self):
print("%s is born a baby..."%self.name)
def cook(self):
print("%s cooking many food,i love it ..."%self.name)
def shopping(self):
print("%s My wife so pretty,dress on beautiful clothes."
"it's just white fu mei's long legs"%self.name)
#两个子类之间不能相互调用类的方法
#m1实例化
m1 = Man("Jordan",22,1000000)
m1.eat()
m1.piao()
m1.sleep()
#w1实例化
w1 = Woman("Lydia",20)
w1.get_birth()
w1.cook()
w1.shopping()