- 36
- 0
- 约 5页
- 2017-03-08 发布于贵州
- 举报
软件架构与设计式实验(结构型模式)
重 庆 大 学
学 生 实 验 报 告
实验课程名称 软件架构与设计模式 开课实验室 DS1501 学 院 2010 年级 数媒2 学 生 姓 名 罗正武 学 号 座机电话号码 开 课 时 间 2012 至 2013 学年第 2学期
总 成 绩 教师签名 软件学院制
《软件架构与设计模式》实验报告
开课实验室:软件学院 年 月 日
学院 软件学院 年级、专业、班 2010 -数媒 -2 罗正武 成绩 课程
名称 软件架构与设计模式 实验项目
名 称 “结构型模式”的应用 指导教师 教师评语
教师签名:
年 月 日 一、实验目的
以设计适配器模式 Adapter 为实验实例,掌握“结构型模式”的工作原理、应用环境和应用方法。
二、实验条件
计算机上安装Word字处理软件、ea软件、Eclipse编程环境。
三、实验内容
用Adapter模式设计一个仿生机器人:
要求机器人可以模拟各种动物行为,在机器人中定义了一系列方法,如机器人叫喊方法cry 、机器人移动方法move 等。如果希望在不修改已有代码的基础上使得机器人能够像狗一样汪汪叫,像狗一样快跑,或者像鸟一样叽叽叫,像鸟一样快快飞,使用适配器模式进行系统设计。
四、实验步骤
1、用UML设计“仿生机器人”的类图。
2、上机测试程序,运行结果。
3、根据类图写出的“仿生机器人”的源代码如下
package factoryMode;
import java.awt.Robot;
class robot public void cry System.out.println 哭泣 ; public void move System.out.println 动起来 ; interface dog public void run ;
public void wang ; public class dogAdapter extends robot implements dog @Override
public void run // TODO Auto-generated method stub System.out.println 狗跑 ; @Override
public void wang // TODO Auto-generated method stub System.out.println 狗汪汪汪 ; public static void main String args[] dogAdapter dogad new dogAdapter ; dogad.run ; dogad.wang ; dogad.cry ; dogad.move ; of support and hanger. Cable hole plugging gaps should use qualified fireproof materials, block surface should have sufficient strength, surface appearance. When cables pass through the firewall, of lax structure of local fire safety clamps. Thermoplastics production, to comply with the process, no bubbles in the thermoplastics pipes, linear nose consistent with the core wire specifications, contact is good, no cracks, break. Tinned copper nose clean solder full exterior surface is smooth without burrs. Control cable Assembly should be fastened, dense, solid, clean, and beautiful. Secondary wiring the cable terminations should be arranged by the actual location of the device line cards, the wiring from the upper to the lower, from left to right in the order. Fixed to maintain consistent spacing between lines, flat, s
原创力文档

文档评论(0)