02-01对象&类

相关概念

1、对象&类

对象,存在的相对独立的个体
具有:静态属性动态行为

类,是对具有相同属性和行为的对象的抽象

2、封装

封装体:把对象的属性和行为组成一个独立的单位
具有独立性、隐藏性

封装体与外部通过有限的接口联系

C++中,类支持数据的封装,对象是数据封装的实现

类中成员有不同的访问权限

3、继承

表现特殊类和一般类的关系,提高了重用性,简化了对于客观事物的描述

支持单重继承多重继承

4、多态性

多态性,一种行为对应着多种不同的实现

体现在:
支持函数重载、运算符重载
支持动态联编

5、消息

允许一个对象与另一个对象的交互的机制

是一个对象要求另一个对象执行某个操作的的规格说明

通过消息传递才能完成对象之间的相互请求或相互协作

组成:
接收消息的对象
消息名
零个/多个参数

性质:
同一个对象可以接收不同形式的多个消息,作出不同的响应
相同形式的消息可以传递给不同的对象,所作出的响应可以是不同的
对消息的响应并不是必需的,对象可以响应消息,也可以不响应

分类:
公有消息(其它对象发出)
私有消息(向自己发出)

6、方法

对象所能执行的操作

组成:
方法的界面(消息的模式,给出方法调用的协议)
方法体(实现某种操作的一系列计算步骤,即一段处理的程序)

C++中,成员函数

消息和方法的关系是:
对象根据接收到的消息,调用相应的方法;反过来,有了方法,对象才能响应相应的消息

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
import java.util.Arrays; import org.apache.http.client.fluent.Request; import ece448.iot_sim.SimConfig; import ece448.iot_sim.Main; public class GradeP2 { public static void main(String[] args) throws Exception { SimConfig config = new SimConfig( 8080, Arrays.asList("xxxx", "yyyy", "zzzz.789"), null, null, null); try (Main m = new Main(config)) { Grading.run(new GradeP2(), 10); } } private String get(String pathParams) throws Exception { return Request.Get("http://127.0.0.1:8080"+pathParams) .userAgent("Mozilla/5.0") .connectTimeout(1000) .socketTimeout(1000) .execute().returnContent().asString(); } public boolean testCase00() throws Exception { String ret = get("/xxxx"); return (ret.indexOf("xxxx is off") != -1) && (ret.indexOf("xxxx is on") == -1) && (ret.indexOf("Power reading is 0.000") != -1); } public boolean testCase01() throws Exception { String ret = get("/xxxx?action=on"); return (ret.indexOf("xxxx is on") != -1) && (ret.indexOf("xxxx is off") == -1); } public boolean testCase02() throws Exception { String ret = get("/xxxx?action=off"); return (ret.indexOf("xxxx is off") != -1) && (ret.indexOf("xxxx is on") == -1); } public boolean testCase03() throws Exception { String ret = get("/xxxx?action=on"); return (ret.indexOf("xxxx is on") != -1) && (ret.indexOf("xxxx is off") == -1); } public boolean testCase04() throws Exception { String ret = get("/xxxx?action=toggle"); return (ret.indexOf("xxxx is off") != -1) && (ret.indexOf("xxxx is on") == -1); } public boolean testCase05() throws Exception { String ret = get("/xxxx?action=toggle"); return (ret.indexOf("xxxx is on") != -1) && (ret.indexOf("xxxx is off") == -1); } public boolean testCase06() throws Exception { String ret = get("/yyyy"); return (ret.indexOf("yyyy is off") != -1) && (ret.indexOf("yyyy is on") == -1); } public boolean testCase07() throws Exception { String ret = get("/xxxx"); return (ret.indexOf("xxxx is on") != -1) && (ret.indexOf("xxxx is off") == -1); } public boolean testCase08() throws Exception { String ret = get("/zzzz.789"); return (ret.indexOf("Power reading is 0.000") != -1); } public boolean testCase09() throws Exception { get("/zzzz.789?action=on"); Thread.sleep(1500); String ret = get("/zzzz.789"); return (ret.indexOf("Power reading is 789.000") != -1); } } private static final Logger logger = LoggerFactory.getLogger(HTTPCommands.class); }请逐句解释一下上述代码
06-12

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值