Page 41 - Python Cơ Bản
P. 41

name = ''
               age = 0


               def __init__(self, name = '', age = 0):
                   self.name = name


                   self.age = age
               def show(self):


                   print 'My name is ', self.name
               def run(self):


                   print 'Animal is running...'
               def go(self):


                   print 'Animal is going...'




           class dog(animal):


               def run(self):
                   print 'Dog is running...'



           myanimal = animal()


           myanimal.show()
           myanimal.run()


           myanimal.go()



           mydog = dog('Lucy')
           mydog.show()


           mydog.run()
           mydog.go()
   36   37   38   39   40   41   42   43   44   45   46