class Animal:     def eat(self):         print "%s 吃 " %self.name     def drink(self):         print "%s 喝 " %self.name     def shit(self):         print "%s 拉 " %self.name     def pee(self):         print "%s 撒 " %self.name class Cat(Animal):     def __init__(self, name):         self.name = name         self.breed = '猫'     def cry(self):         print '喵喵叫' class Dog(Animal):          def __init__(self, name):         self.name = name         self.breed = '狗'              def cry(self):         print '汪汪叫'          # ######### 执行 ######### c1 = Cat('小白家的小黑猫') c1.eat() c2 = Cat('小黑的小白猫') c2.drink() d1 = Dog('胖子家的小瘦狗') d1.eat()
点赞 1

相关推荐

03-01 19:30
已编辑
南京大学 Java
点赞 评论 收藏
分享
LZHR:老哥你从投递简历测评完到一面中间隔了多久呀,我这边已经过了五天了仍显示简历筛选中是不是就是挂了
腾讯求职进展汇总
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务