<p style=line-height: 150%>接上回:
<p style=line-height: 150%><a href="http://www.csdn.net/develop/read_article.asp?id=11111">http://www.csdn.net/develop/read_article.asp?id=11111</a>
<p style=line-height: 150%>用前锋,前卫甚至后卫来多点进攻,是最好的进攻方法,
在这里可以使用abstract factory模式,用一个abstract
factory来创建一个统一的进攻位置,然后派生出具体的
concrete factory(具体位置)来生产concrete product
(进球),所有的进攻由client class(教练)来指挥。
缺点是基本打发已经定死,没有什么创造性
的进球方法,如肩部进球,胸部进球和“上
帝之手”等等:p
代码如下:
t位置 = class(tobject)
<p style=line-height: 150%> public
<p style=line-height: 150%> constructor create;
<p style=line-height: 150%> destructor destroy; override;
<p style=line-height: 150%>
function 头球(aowner: tcomponent): t头球得分; virtual; abstract;
<p style=line-height: 150%> function 近射(aowner: tcomponent): t近射得分; virtual; abstract;
<p style=line-height: 150%> function 远射(aowner: tcomponent): t远射得分; virtual; abstract;
<p style=line-height: 150%> end;
<p style=line-height: 150%>t前锋 = class(t位置)
<p style=line-height: 150%> public
<p style=line-height: 150%> { concrete constructors }
<p style=line-height: 150%> function 前锋头球(aowner: tcomponent): t前锋头球得分; override;
<p style=line-height: 150%> function 前锋近射(aowner: tcomponent): t前锋近射得分; override;
<p style=line-height: 150%> function 前锋远射(aowner: tcomponent): t前锋远射得分; override;
<p style=line-height: 150%> end;
<p style=line-height: 150%>t后卫 = class(t位置)
<p style=line-height: 150%> public
<p style=line-height: 150%> { concrete constructors }
<p style=line-height: 150%> function 后卫头球(aowner: tcomponent): t后卫头球得分; override;
<p style=line-height: 150%> function 后卫近射(aowner: tcomponent): t后卫近射得分; override;
<p style=line-height: 150%> function 后卫远射(aowner: tcomponent): t后卫远射得分; override;
<p style=line-height: 150%> end;
<p style=line-height: 150%>
相关阅读:
全‘心’康复,全新旅程
足球战术之strategy篇
足球战术之flyweight篇
足球战术->多点进攻之Abstract Factory篇
足球战术->组合进攻之composite篇