实验7系统类图的创建.docx
《实验7系统类图的创建.docx》由会员分享,可在线阅读,更多相关《实验7系统类图的创建.docx(15页珍藏版)》请在冰豆网上搜索。
实验7系统类图的创建
实验7系统类图的创建
一、实验准备
开始本实验前要求完成对类图的学习内容
二、实验目标
1)在浏览器中添加类图.
2)在类图中添加Subsystem.
3)在类图中添加Class.
4)在类图中添加Iinterface.
5)在类图中添加Association.
6)在类图中添加DirectAssociation.
三、实验结果
1)熟练创建类图
四、基本实验任务
任务一:
创建Subsystem
1.
单击[Toolbox]->[Class]->[Subsystem]按钮.
2.
在[mainwindow]中选择要放置Subsystem的位置.
3.
Subsystem就创建完毕,在对话框中可以输入Subsystem的名字。
4.
最后单击[Enter]完成这一过程.
任务二:
创建providinginterfaceofsubsystem.
1.
创建interface和susbystem.
2.
单击[Toolbox]->[Realization].
3.
从subsystem拉到interface.
4.
在interface和subsystem之间的providinginterfacerelationship就被建立了.
快速创建interface和realization的方法
1.
双击subsystem打开快速对话框
2.
按下图格式输入text
3.
单击[Enter]完成.
任务三:
添加operation到subsystem
1.
右击Subsystem,在弹出菜单选择[CollectionEditor]
2.
在[collectioneditor]对话框,点击[Insert]按钮添加operation
3.或则点击快速对话框右边的按钮,如下图
4.
一个新的operation就被建立了。
任务四:
创建类
1.
单击[Toolbox]->[Class]->[Class].
2.
在[mainwindow]中选择要放置class的位置.
3.
输入classname,单击[Enter]完成创建.
任务5:
添加属性
有三种方法把属性添加到类中.
使用快速对话框
使用[mainwindow]或[modelexplorer]中的model
使用[collectioneditor]
第一种方法:
1.
双击class.
2.
单击[AddAttribute]按钮,就成功添加了一个属性.
第二种方法:
1.
在[mainwindow]或[modelexplorer]选到class.
2.
在选中的class上右击,选择弹出菜单的[Add]->[Attribute].
第三种方法:
1.
在弹出菜单中选择[CollectionEditor...].
2.
在[collectioneditor]的[attribute]页签,点击下图鼠标处的按钮,完成添加.
任务六:
添加Operation
和添加属性类似,有三种方法添加Operation.
使用快速对话框
在[mainwindow]或[modelexplorer]中添加
使用[collectioneditor]
第一种方法
1.
双击class.
2.
点击[AddOperation]按钮,完成操作.
第二种方法,在[mainwindow]或[modelexplorer]中选中class,右击选中的class,选择弹出菜单中的[Add]->[Operation],完成操作.
第三种方法,
1.
选择弹出菜单中的[CollectionEditor...].
2.
在[collectioneditor]中的[operations]页,点击下图中的按钮,完成操作.
任务七:
给operation添加参数
1.
在[modelexplorer]中选中operation,右击,选择弹出菜单中的[Add]->[Parameter],参数就被添加到operation中.
2.
或则选择弹出菜单中的[CollectionEditor...].
3.
或则单击protertites窗口中的[Parameters].
4.
在[collectioneditor]中的[Parameters]页面,点击Insert添加parameters
任务八:
给operation添加exception
前提条件,exception必须存在.
1.
点击properties窗中的[RaisedSignals]如下图.
2.
在[collectioneditor]的[RaisedSignals]页签,点击Insert按钮
3.
在[SelectaSignal]对话框,选择一个或多个exception,点击[ok]完成
4.
结果如下图.
任务九:
创建Interface
1.
单击[Toolbox]->[Class]->[Interface].
2.
在[mainwindow]中点击要放置的位置,输入interface的名字
3.
点击[enter],完成操作.
任务十一:
创建Exception
1.
点击[Toolbox]->[Class]->[Exception].
2.
在[mainwindow]中选择放置的位置。
任务十二:
建立Association
1.
点击[Toolbox]->[Class]->[Association].
2.
在[mainwindow].中从一个class拉向另一个class
3.
两个class之间的association就被建立了,如下图.
任务十三:
快速建立一对多的association
1.
双击class,在快速对话框输入下图中的text.
2.
三个带association的class就被建立了.