Page 335 - C++
P. 335

(d)     Answer the questions (i) to (iv) based on the following :                       4

                   Class Top1(object):

                         def __init__(self,tx):                            #Line 1
                              self.X=tx                                    #Line 2

                         def ChangeX(self,tx):
                              self.X=self.X+tx

                         def ShowX(self):
                              print self.X


                   Class Top2(object):
                         def __init__(self,ty):                            #Line 3

                              self.Y=ty                                    #Line 4
                         def ChangeY(self,ty):
                              self.Y=self.Y+ty
                         def ShowY(self):

                              print self.Y,


                   class Bottom(Top1,Top2):
                         def __init__(self,tz):                            #Line 5
                              self.Z=tz                                    #Line 6

                         Top2.__init__(self,2*tz):                         #Line 7

                         Top1.__init__(self,3*tz):                         #Line 8
                         def ChangeZ(self,tz):
                              self.Z=self.Z+tz
                              self.ChangeY(2*tz)

                              self.ChangeX(3*tz)
                         def ShowZ(self):
                              print self.Z,

                              self.ShowY()
                              self.ShowX()
                         B=Bottom(1)

                         B.ChangeZ(2)
                         B.ShowZ()

      91                                            16
   330   331   332   333   334   335   336   337   338   339   340