#coding=utf-8
class Wangjianlin:
def __init__(self):
self._name = "Wang Jianlin"
self .__ post = "Wanda chairman"
self._money=10000000000
def buy(self,name,price):
if price>1000000:
print ( 'too expensive!')
return
self._money-=price
print ( "spent% s, purchased% s"% (price, name))
def say(self):
print ( "I'm% s, I have money:% s, duty is:% s"% (self._name, self._money, self .__ post))
class Wangsicong (Wangjianlin):
pass
wangjianli = Wangjianlin ()
wangjianli.say ()
wangjianli.buy ( "red brush to net yacht", 5 million)
wangjianli.buy ( "brush to the network Red F-20", 500,000)
wangjianli.say ()
"""
When the subclass does not __init __ () method is called the parent class __init __ () method
Also inherits the properties of the parent class (non-proprietary)
"""
WSC = Wangsicong ()
"""
Inherits the parent class say ()
"""
wsc.say()