电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

利用UML类图设计Java应用程序详解

利用UML类图设计Java应用程序详解_第1页
1/35
利用UML类图设计Java应用程序详解_第2页
2/35
利用UML类图设计Java应用程序详解_第3页
3/35
利用UML 类图设计Jav a 应用程序详解(一) 在第一部分中,我们实现了5 个类。在本部分中,我们接着说明如何利用UML 类图来设计余下的各个类。为减少篇幅,本部分着重讲解UML 类图及应用,对Jav a 实现代码不再详细描述。 下载本文全部代码 六、CGPoint 类 CGPoint 类说明了如何利用非抽象类扩展抽象类。CGPoint 类是 CGObject 的子类,CGPoint类扩展了 CGObject 类,CGPoint 类没有再它所继承的变量中增加变量,它所声明的方法只有构造函数和要求它实现的抽象方法。其类图如下: Jav a 实现代码为: // CGPoint.java public class CGPoint extends CGObject { // Method declarations public CGPoint(int x, int y,char ch) { location = new Point(x,y); drawCharacter = ch; } public CGPoint(int x, int y) { this(x,y,'+'); } public CGPoint(Point p) { this(p.getX(),p.getY(),'+'); } public CGPoint(Point p,char ch) { this(p.getX(),p.getY(),ch); } public void display(PrintCGrid grid) { grid.setCharAt(drawCharacter,location); } public void describe() { System.out.print("CGPoint "+String.valueOf(drawCharacter)+" "); System.out.println(location.toString()); } } 七、CGBox 类 CGBox 类也扩展了 CGObject 类。CGBox 类提供了在网格上显示矩形的附加变量。CGBox类的类图如下: 相应的代码为: // CGBox.java public class CGBox extends CGObject { // Variable declarations protected Point lr; // Lower right corner of a box // Method declarations public CGBox(Point ulCorner, Point lrCorner,char ch) { location = ulCorner; lr = lrCorner; drawCharacter = ch; } public CGBox(Point ulCorner, Point lrCorner) { this(ulCorner,lrCorner,'#'); } public void display(PrintCGrid grid) { int width = lr.getX() - location.getX() + 1; int height = lr.getY() - location.getY() + 1; Point topRow = new Point(location); Point bottomRow = new Point(location.getX(),lr.getY()); for(int i=0; i

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

利用UML类图设计Java应用程序详解

确认删除?
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群