Hello,
let's take this code:
With the line "Local castedalien:TAlien = TAlien(alien) "
I can call the right methods of the objects, but how
do I get access to the fields of the objects that are not Baseobjects?
I can use a method like "ReceiveHealth:Int()" which will
return the correct value(2,3) but is there a smarter way?
let's take this code:
SuperStrict Type TAlien Field health:Int = 1 ' Method PrintHealth() End Method End Type Type TAlienSmall Extends TALien Field health:Int = 2 ' Method PrintHealth() Print "Method PH in TAlienSmall" End Method End Type Type TAlienBig Extends TAlien Field health:Int = 3 Method PrintHealth() Print "Method PH in TAlienBig" End Method End Type ' Main Local alienlist:TList = New TList Local as:TalienSmall = New TAlienSmall Local ab:TAlienBig = New TAlienBig alienlist.AddLast(as) alienlist.AddLast(ab) For Local alien:TAlien = EachIn alienlist Local castedalien:TAlien = TAlien(alien) ' casting type of object ' castedalien.PrintHealth Print castedalien.health Next
With the line "Local castedalien:TAlien = TAlien(alien) "
I can call the right methods of the objects, but how
do I get access to the fields of the objects that are not Baseobjects?
I can use a method like "ReceiveHealth:Int()" which will
return the correct value(2,3) but is there a smarter way?