Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ---------------------------------
- # Assume methods starting with underscore
- # to be private. They are not mentioned
- # in public API documentation
- _totalPopulation = 0
- class C1 :
- def __init__ (self) :
- global _totalPopulation
- _totalPopulation += 1
- #
- def say (self) :
- print ("C1: hello")
- #
- def _c1OnlySay (self) :
- print ("C1 says hi")
- #
- def _myName (self) :
- return "C1"
- #
- #
- class C2 :
- def __init__ (self) :
- global _totalPopulation
- _totalPopulation += 1
- #
- def say (self) :
- print ("C2: hello")
- #
- def _c2OnlySay (self) :
- print ("C2 says hello")
- #
- def _myName (self) :
- return "C2"
- #
- def talk (obj) :
- obj.say ()
- #
- def c1TalksToC2 (c1Obj, c2Obj) :
- c1Obj.say ()
- c2Obj.say ()
- c1Obj._c1OnlySay ()
- c2Obj._c2OnlySay ()
- #
- def totalPopulationOfC1AndC2 () :
- print ("Total Population of C1 and C2 is :", _totalPopulation)
- #
- #---------------- EVERYTHING BEFORE THIS IS CONSIDERED COMPILED -----------
- class C3 (C1, C2) :
- def say (self) :
- # I want C2.say first and then C1.say twice
- C2.say (self)
- C1.say (self)
- C1.say (self)
- #
- #
- obj1 = C3 ()
- obj2 = C3 ()
- c1TalksToC2 (obj1, obj2)
- totalPopulationOfC1AndC2 ()
Advertisement
Add Comment
Please, Sign In to add comment