#!/usr/bin/python
#coding:utf-8
# animal is-a object(yes,sort of sonfusing)look at the extra credit
class Animal(objeck):
pass #Dog 类 继承 Animal
class Dog(Animal):
def __init__(self,name):
#对 对象Dog赋值 name
self.name =name
#Cat 类 继承 Animal
class Cat(Animal):
def __init__(self,name):
#对 对象 Cat 赋值 name
self.name=name #建立类 Person
class Person(objeck):
def __init__(self,name):
##对 对象 Person 赋值 name
self.name = name #Person has-a pet of some kind
self.pet = none #类 Employee 继承 Person
class Employee(Person):
def __init__(self,name,salary)
#? what is this strange magic?
#使用超级继承 super ,对 Employee 增加初始化 init
super(Employee,self).__init__(name)
# 赋值 salary
self.salary= salary #建 类 Fish
class Fish(objeck):
pass #Salmon 类 继承 Fish
class Salmon(Fish):
pass
#Halibut 类 继承 Fish
class Halibut(Fish):
pass #rover is-a Dog
rover = Dog('rover')
#satan is-a Cat
satan = Cat('satan')
#mary is-a Person
mary = Person('mary')
#mary has-a pet,pet(name) is satan
mary.pet = satan
#frank is-a Employee frank.salary = 12000
frank = Employee('frank',12000)
#fank has-a pet,pet(name) = rover
frank.pet rover
#flipper is-a Fish
flipper =Fish()
#crouse is-a Salmon
crouse =Salmon()
#harry is-a Halbut
harry = Halibut()

没有写别的

最新文章

  1. css 隔行变色,表单布局
  2. [Linux]服务管理:rpm包, 源码包
  3. no2.crossdomain.xml批量读取(待完善)
  4. HDU 5317 RGCDQ
  5. bootstrap完整导航栏
  6. 河南多校联合训练 南阳理工 1261 音痴又音痴的LT
  7. AVL树的插入与删除
  8. ul 和 ol 标签的相关设置
  9. IIS 常用命令
  10. 云服务jdk 升级为 OpenJDK11
  11. BZOJ.4589.Hard Nim(FWT)
  12. LeetCode OJ 94. Binary Tree Inorder Traversal
  13. centos 7 下 TFTP服务器安装
  14. Django实现微电影网站
  15. (原创)hibernate 一对多建表实例详解 附上各个注释的含义
  16. 请编写一个C函数,将一个字符串逆序
  17. iOS与硬件通讯(socket,data拼接,发送指令,解析指令)
  18. Jmeter性能指标分析
  19. 关于kafka的一些问题理解
  20. URIEncoding与useBodyEncodingForURI 在tomcat中文乱码处理上的区别

热门文章

  1. SQL Server 批量 删除表索引
  2. Linux学习--第五天--vim使用、rpm命令
  3. nodejs 操作 mysql
  4. python基础操作---tuple
  5. qt04 中文显示问题
  6. expect实现远程主机自动执行命令脚本
  7. vue 报错 :属性undefined(页面成功渲染)
  8. HBase设计规范(转载)
  9. 6398. 【NOIP2018模拟10.30】Generator(树状数组区间修改)
  10. 10分钟学会React Context API