OOP Interfaces

BlitzMax Forums/BlitzMax Beginners Area/OOP Interfaces

Yes and no. Its doable, but it will become far harder, if you TBook is not extended from ITWeapon (if you want it to use as weapon, it should be extended from one, otherwise the design is flawed)


In that case you would be forced to use :Object as type and then:

Type TPlayer

     field weapon:object

     method attack()
          if ITWeapon(weapon) <> null
             ITWeapon(weapon).attack()
          elseif TBook(weapon) <> null
             TBook(weapon).attack()
          endif   
     end method

End Type