lol, I knew you were going to ask for the ability to delete turrets - I toyed with the idea of including it originally. The reason I left it out is because it could lead to confusion, and here's why:
Say you initially create a tank with 5 turrets. They will be numbered sequentially from 1 to 5 so that you can use the get_turret() function to access a specific turret. Fine and dandy but if you then delete turret number 3, say, all the turrets above it 'drop down' the list so: what was turret 4 is now turret 3, and what was turret 5 is now turret 4.
Anyway, as long as you bear this in mind, here's the function to delete a turret:
Say you initially create a tank with 5 turrets. They will be numbered sequentially from 1 to 5 so that you can use the get_turret() function to access a specific turret. Fine and dandy but if you then delete turret number 3, say, all the turrets above it 'drop down' the list so: what was turret 4 is now turret 3, and what was turret 5 is now turret 4.
Anyway, as long as you bear this in mind, here's the function to delete a turret:
; ; Delete a turret from the specified tank. ; Function delete_turret%(tank.tankType, turretNo%) ; Return -1 if turretNo is invalid. If (turretNo < 1) Or (turretNo > tank\totalTurrets) Then Return -1 ; Walk along turret linked list until we reach the requested turret. this.turretType = tank\turretList prev.turretType = Null For n = tank\totalTurrets-1 To turretNo Step -1 prev = this this = this\nextLink Next ; Remove turret from linked list. If prev <> Null prev\nextLink = this\nextLink Else tank\turretList = this\nextLink EndIf ; Free the turret type. Delete this ; Decrease the total count of turrets belonging to this tank. tank\totalTurrets = tank\totalTurrets - 1 Return tank\totalTurrets End Function