class Command { // Fields private var receiver: Receiver ; // Constructors private function Command( receiver:Receiver ) { this.receiver = receiver; } // Methods public function Execute():Void{}; } // "Receiver" class Receiver { // Methods public function Action():Void { trace("Called Receiver.Action()"); } } // "Invoker" class Invoker { // Fields private var command:Command ; // Methods public function SetCommand( command:Command ):Void { this.command = command; } public function ExecuteCommand():Void { command.Execute(); } } // "ConcreteCommand" class ConcreteCommand extends Command { // Constructors public function ConcreteCommand(receiver:Receiver) { super(receiver); } // Methods public function Execute():Void { receiver.Action(); } } //client.fla // Create receiver, command, and invoker var r:Receiver = new Receiver(); var c:Command = new ConcreteCommand(r); var i:Invoker = new Invoker(); // Set and execute command i.SetCommand(c); i.ExecuteCommand(); //Called Receiver.Action()
Command模式
博客展示了Command模式的代码实现。定义了Command、Receiver、Invoker和ConcreteCommand类,通过创建实例并调用方法,最终执行了Receiver的Action方法,体现了Command模式的使用逻辑。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Stable-Diffusion-3.5
图片生成
Stable-Diffusion
Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率


被折叠的 条评论
为什么被折叠?



