交通管理系统----面向对象的分析与设计:
2013-12-11 21:45
239 查看
交通管理系统----面向对象的分析与设计:
面向对象的分析与设计:
谁拥有数据,谁就对外提供操作这些数据的方法!
典型案例:
1.人在黑板上画圆 对象有:person, blakboard, circle 其中 画圆这个动作draw()是圆身上的动作!原因是:画圆需要圆心和半径,这都是圆上的数据
2.列车司机紧急刹车 对象有:司机和列车 其中 刹车这个动作 是车上的动作
3.售货员正在统计售货小票上的总金额 对象有:售货员 和小票 其中 统计总金额是小票上的方法
4.两块石头磨成一把石刀,石刀可以砍树,砍成木材,木材做成椅子!
其中对象有:stone, stoneKnife.tree.material,chair
stoneKdnife=KnifeFactory.createKnife(stone,stone);
material=stoneKnife.cut(tree);
chair=ChairFactory.makeChair(material);
5.球从一根绳子的一段移动到了另一端!
class Rope{
private Point start;
private Point end;
public Rope(Point start,Point end){
This.start=start;
This.end=end;
}
public Point nextPoint(Point currentPont){
}
}
class Ball{
private Rope rope;
private Point currentPoint;
public Ball(Rope rope,Point startPont){
this.rope=rope;
this.currentPoint=startPont;
}
public void move(){
currentPoint=rope.nextPont(currentPoint);
System.out.println(“小球移动到了”+currentPoint);
}
}
面向对象的分析与设计:
谁拥有数据,谁就对外提供操作这些数据的方法!
典型案例:
1.人在黑板上画圆 对象有:person, blakboard, circle 其中 画圆这个动作draw()是圆身上的动作!原因是:画圆需要圆心和半径,这都是圆上的数据
2.列车司机紧急刹车 对象有:司机和列车 其中 刹车这个动作 是车上的动作
3.售货员正在统计售货小票上的总金额 对象有:售货员 和小票 其中 统计总金额是小票上的方法
4.两块石头磨成一把石刀,石刀可以砍树,砍成木材,木材做成椅子!
其中对象有:stone, stoneKnife.tree.material,chair
stoneKdnife=KnifeFactory.createKnife(stone,stone);
material=stoneKnife.cut(tree);
chair=ChairFactory.makeChair(material);
5.球从一根绳子的一段移动到了另一端!
class Rope{
private Point start;
private Point end;
public Rope(Point start,Point end){
This.start=start;
This.end=end;
}
public Point nextPoint(Point currentPont){
}
}
class Ball{
private Rope rope;
private Point currentPoint;
public Ball(Rope rope,Point startPont){
this.rope=rope;
this.currentPoint=startPont;
}
public void move(){
currentPoint=rope.nextPont(currentPoint);
System.out.println(“小球移动到了”+currentPoint);
}
}
相关文章推荐
- VI编辑器常用快捷键
- 使用apache实现ftp功能demo
- Subsets II
- c语言预处理命令
- C# winform一个窗口去触发另一个窗口的方法
- 双色汉诺塔
- UNIX动态链接库简介
- Restore HBase Data
- 敏捷之旅2013 北京站-精益敏捷交响曲 12.21
- Java基础加强: Jdk1.5新特性 枚举
- MYSQL基础语法
- 告别臃肿~精简安装Visual Studio 2012
- iOS中 UIWebView 基本用法
- poj 1185
- 浅谈Android输出apk大小与classpath文件
- OpenCV 脸部跟踪(1)
- Mac OS X 程序员利器 – Homebrew安装与使用
- arcgis api for javascript中使用proxy.jsp
- 新人新天地
- KDB使用指南