# -*- coding: utf-8 -*-
"""
Created on Mon Mar 26 17:17:02 2018
@author: mz
"""
class ICommand(object):
def __init__(self, rhs):
self.rcv = rhs
def Excute(self):
pass
class LeftCommand(ICommand):
def Excute(self):
self.rcv.AtackLeft()
class RightCommand(ICommand):
def Excute(self):
self.rcv.AtackRight()
#receiver
class Boxer(object):
def AtackLeft(self):
print("left Atack")
def AtackRight(self):
print("Right Atack")
#Invoker
class Coach(object):
def TunLeft(self, command):
command.Excute()
def TurnRight(self,command):
command.Excute()
if "__main__" ==
Python 命令模式
最新推荐文章于 2024-08-25 15:06:04 发布
本文介绍了Python中命令模式的概念和应用,通过实例展示了如何使用命令模式进行设计和实现,帮助读者理解这种设计模式在软件开发中的作用和价值。
摘要由CSDN通过智能技术生成