软件设计模式复习题(16)

2020-11-29 00:35

undoC.add (comd); comd.Execute (); redoC.add(comd); comd.Execute();}

public void paintHandler(object sender, PaintEventArgs e) {

Graphics g = e.Graphics ; blueC.draw(g); redC.draw (g); }

[STAThread]

static void Main(){

Application.Run(new Form1());} Command:

public interface Command { void Execute(); void Undo(); void Redo(); bool isUndo(); bool isRedo();}

public class UndoComd:Command { public static ArrayList undolist; public UndoComd(){

undolist = new ArrayList();} public void add(Command comd) { if(! comd.isUndo ()) {

undolist.Add(comd);}} public bool isUndo() { return true;} public void Undo() { } public void Execute() { int unIndex =undolist.Count - 1; if (unIndex >= 0){

Command cmd = (Command)undolist[unIndex]; cmd.Undo();

RedoComd.redolist = new ArrayList(); RedoComd.redolist.Add(cmd); undolist.Remove(unIndex);}}} public class RedoComd:Command { public static ArrayList redolist; public RedoComd(){

redolist = new ArrayList();} public void add(Command comd) { if(! comd.isRedo ()) {

redolist.Add(comd);}} public bool isRedo() {


软件设计模式复习题(16).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:二年级100以内加减乘除混合口算题(100题1页)

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: