·ÖÀà
Éè¼ÆÄ£Ê½Ö®¹¤³§·½·¨ FACTORY METHOD(Èý)¡¬
| ¡¡¡¡ÔÚÕâ¸öС³ÌÐòÔÚʵ¼ÊÓ¦ ʵÀý»¯StraightSeeding Àà | Óõ±ÖУ¬»á·¢Ïִ󲿷ֹ¤×÷ÔÚSt £¬¸´ÖÆ¡¢ÐÞ¸ÄÓÎÓ¾Ô˶¯Ô±µÄ¼¯ºÏ | raight SeedingÀàÖÐÍê³ÉµÄ¡£ÎÒÃÇ ºÍËùÊôÓ¾µÀλÖᣠ|
| ¡¡¡¡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) |
| ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡laneOrde | r = calcLaneOrder(numLanes) |
| ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡count = sw.Count |
| ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡lastHeat = count Mod numLanes |
| ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡If (lastHeat <¡¡3) And lastHeat > 0 Then |
| ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡last | Heat = 3¡¡ 'last heat must h | ave 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(CTy | pe(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(B | yVal swmrs As Swimmers, ByVa | l 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(B | yVal swmrs As Swimmers, ByVa | l 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).se | tLane(CType(laneOrder(j), Integer)) |
| ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡sw.swm(i).se | tHeat(numheats - k + 1) |
| ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡i = i + 1 |
| ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Next k |
| ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Next j |
| ¡¡¡¡¡¡¡¡¡¡¡¡End If |
| ¡¡¡¡¡¡¡¡End Sub |
| ¡¡¡¡¡¡¡¡'----- |
| ¡¡¡¡End Class |
| ¡¡¡¡ÔËÐÐ |
| ¡¡¡¡ÔÚÕâ¸öÀý×Óµ±ÖУ¬ÎÒÃÇ TimedFinalEvent ÀàºÍPrel | ʹÓÃÍê³É500m×ÔÓÉÓ¾ºÍ100m×ÔÓÉ imEventÀà¡£ | Ó¾µÄÔ˶¯Ô±ÁбíÀ´´´½¨ |