国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

設計模式之工廠方法(FACTORY METHOD))(三)

2024-07-21 02:23:36
字體:
來源:轉載
供稿:網友
(接上頁)

straight seeding類



在這個小程序在實際應用當中,會發現大部分工作在straight seeding類中完成的。我們實例化straightseeding 類,復制、修改游泳運動員的集合和所屬泳道位置。



public class straightseeding

inherits seeding

public overrides sub seed()

dim lastheat as integer

dim lastlanes as integer

dim i, j, count, heats as integer

dim swmr as swimmer

try

sw = sort(sw)

laneorder = calclaneorder(numlanes)

count = sw.count

lastheat = count mod numlanes

if (lastheat < 3) and lastheat > 0 then

lastheat = 3 'last heat must have 3 or more

end if

count = sw.count

lastlanes = count - lastheat

numheats = lastlanes / numlanes

if (lastheat > 0) then

numheats = numheats + 1

end if

heats = numheats

'place heat and lane in each swimmer's object

j = 0

for i = 0 to lastlanes - 1

swmr = sw.swm(i)

swmr.setlane(ctype(laneorder(j), integer))

j = j + 1

swmr.setheat(heats)

if (j >= numlanes) then

heats = heats - 1

j = 0

end if

next i

'add in last partial heat

if (lastheat > 0) then

if j > 0 then

heats = heats - 1

end if

j = 0

for i = lastlanes to count - 1

swmr = ctype(sw(i), swimmer)

swmr.setlane(ctype(laneorder(j), integer))

j = j + 1

swmr.setheat(heats)

next i

end if



catch e as exception

console.writeline(i.tostring + j.tostring + e.tostring)

console.writeline(e.stacktrace)

end try

end sub

'-----

public sub new(byval swmrs as swimmers, byval lanes as integer)

mybase.new(swmrs, lanes)

end sub

end class

當調用getswimmers方法時,straightseeding 類將創建被選拔的游泳運動員數組。

circle seeding類



circleseeding 類是從straightseeding 類派生的。



public class circleseeding

inherits straightseeding



private circlesd as integer

'-----

public sub new(byval swmrs as swimmers, byval lanes as integer)

mybase.new(swmrs, lanes)



end sub

'-----

public overrides sub seed()



dim i, j, k, numheats as integer

laneorder = calclaneorder(numlanes)

sw = sort(sw) '排序



mybase.seed()

numheats = mybase.getheats

if (numheats >= 2) then

if (numheats >= 3) then

circlesd = 3

else

circlesd = 2

end if

i = 0



for j = 0 to numlanes - 1

for k = 1 to circlesd

sw.swm(i).setlane(ctype(laneorder(j), integer))

sw.swm(i).setheat(numheats - k + 1)

i = i + 1

next k

next j

end if

end sub

'-----

end class



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 贵南县| 察隅县| 历史| 新津县| 比如县| 徐汇区| 常熟市| 广河县| 仁布县| 原阳县| 汉沽区| 宁津县| 浮梁县| 张家界市| 顺平县| 彭水| 崇左市| 沾化县| 灵山县| 湖北省| 阳城县| 延庆县| 荥经县| 新巴尔虎左旗| 青神县| 平遥县| 平阳县| 商水县| 古蔺县| 油尖旺区| 宝坻区| 克拉玛依市| 民权县| 黑河市| 合山市| 佛学| 鹰潭市| 海南省| 普格县| 麻江县| 邳州市|