足球戰(zhàn)術(shù)->多點進攻之Abstract Factory篇
時間:2024-10-20 來源: 作者: 我要糾錯
<p style=line-height: 150%>接上回:<p style=line-height: 150%><A >http://www.csdn***/develop/read_article.asp?id=11111</A><p style=line-height: 150%>用前鋒,前衛(wèi)甚至后衛(wèi)來多點進攻,是最好的進攻方法,
在這里可以使用abstract factory模式,用一個abstract
factory來創(chuàng)建一個統(tǒng)一的進攻位置,然后派生出具體的
concrete factory(具體位置)來生產(chǎn)concrete product
(進球),所有的進攻由client class(教練)來指揮。
缺點是基本打發(fā)已經(jīng)定死,沒有什么創(chuàng)造性
的進球方法,如肩部進球,胸部進球和“上
帝之手”等等: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后衛(wèi) = class(T位置)<p style=line-height: 150%> public<p style=line-height: 150%> { concrete constructors }<p style=line-height: 150%> function 后衛(wèi)頭球(AOwner: TComponent): T后衛(wèi)頭球得分; override;<p style=line-height: 150%> function 后衛(wèi)近射(AOwner: TComponent): T后衛(wèi)近射得分; override;<p style=line-height: 150%> function 后衛(wèi)遠射(AOwner: TComponent): T后衛(wèi)遠射得分; override;<p style=line-height: 150%> end;<p style=line-height: 150%>
標簽: