OOP Interfaces

BlitzMax Forums/BlitzMax Beginners Area/OOP Interfaces

You simply have to define a type like

Type ITWeapon abstract
   method attack() abstract
   ...
end type


Which is extended for any implementation of weapon.

type TSword extends ITWeapon
   method attack()
      ' Do something here
   end method
end type



With the usage of the abstract class, you can guarantee, that the method attack is present as all extending classes must implement it. You do not need to typecast for this usage as well, as the method was present in the "baseclass"