Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Design Pattern & UML  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:关于command的模式中Invoker对象? [Re:jameszhang]
jameszhang



CJSDN高级会员


发贴: 1594
积分: 111
于 2004-12-03 14:17 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我的代码,各位给点意见:

public class ClientB
{
public ClientB()
{
}

public static void main(String args[])
{
DrawPane pane = new DrawPane();
LineShape line = new LineShape();
CircularShape circular = new CircularShape();
QuadrateShape quadrate = new QuadrateShape();

pane.drawObject(line);
pane.drawObject(circular);
pane.drawObject(quadrate);

}

}

interface ShapeObject
{
public String getShape();
public void draw();
}

class DrawPane
{
java.util.ArrayList shapeList = new java.util.ArrayList();

public void drawObject(ShapeObject so)
{
shapeList.add(so);
this.repaint();
System.out.println("--------------------------");
}

public void repaint()
{
for(int i=0;i<shapeList.size();i++)
{
System.out.print(i+":");
((ShapeObject)shapeList.get(i)).draw();
}

}

}

class LineShape implements ShapeObject
{
public String getShape()
{
return "画线";
}
public void draw()
{
System.out.println(this.getShape());
}
}

class CircularShape implements ShapeObject
{
public String getShape()
{
return "画圆";
}

public void draw()
{
System.out.println(this.getShape());
}

}

class QuadrateShape implements ShapeObject
{
public String getShape()
{
return "画方";
}

public void draw()
{
System.out.println(this.getShape());
}


jameszhang edited on 2004-12-03 16:01

"First they ignore u, then they laugh at u, then they fight u, then u will win

Mahatma Gandhi"


话题树型展开
人气 标题 作者 字数 发贴时间
12340 关于command的模式中Invoker对象? jameszhang 69 2004-12-01 15:40
10416 Re:关于command的模式中Invoker对象? wes109 654 2004-12-01 18:30
11006 Re:关于command的模式中Invoker对象? jameszhang 256 2004-12-02 08:29
10360 Re:关于command的模式中Invoker对象? jameszhang 122 2004-12-01 20:17
10311 Re:关于command的模式中Invoker对象? floater 415 2004-12-02 00:01
10273 Re:关于command的模式中Invoker对象? floater 175 2004-12-02 23:14
10252 Re:关于command的模式中Invoker对象? wes109 339 2004-12-03 09:10
10146 Re:关于command的模式中Invoker对象? jameszhang 1581 2004-12-03 14:17
10261 Re:关于command的模式中Invoker对象? jameszhang 14 2004-12-03 14:28
10526 Re:关于command的模式中Invoker对象? WeiterWay 478 2004-12-03 15:30
12677 Re:关于command的模式中Invoker对象? jameszhang 527 2004-12-03 16:02

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923