Question about Type Extends Type

BlitzMax Forums/BlitzMax Programming/Question about Type Extends Type

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Type T_Component

    Global Component_Blank:T_Component=New T_Component
    Global Component_Radar:T_Component=New T_Radar
    Global Component_Thruster:T_Component=New T_Thruster
    Global Component_Drone:T_Component=New T_Drone
	
	Method Radar()
		Print "Radar Mod Not Installed"
	End Method
	
	Method Thruster()
		Print "Thruster Mod Not Installed"
	End Method
	
	Method Drone()
		Print "Drone Mod Not Installed"
	End Method
End Type



Type T_Radar Extends T_Component
	Method Radar()
		Print "LEVEL 1 Radar Installed"
	End Method
End Type

Type T_Thruster Extends T_Component
	Method Thruster()
		Print "LEVEL 1 Thruster Installed"
	End Method
End Type

Type T_Drone Extends T_Component
	Method Drone()
		Print "LEVEL 1 Combat Drone Installed"
	End Method
End Type

Type NT_ship
	Field Name$
	Field Class$
	Field Radar:T_Component
	Field Thruster:T_Component
	Field Drone:T_Component
	
	Function Create:NT_Ship(_Name$)
		Local i:NT_Ship=New NT_Ship
		i.Radar=T_Component.Component_Blank
		i.Thruster=T_Component.Component_Blank
		i.Drone=T_Component.Component_Blank
		i.Name$=_Name$
		I.Class$="NT_Ship"
		i.ID
		Return i
	End Function
	
	Method ID()
		Print "~n ~n ~n ~n"
		Print "Ship Name: "+Name$
		Print "Ship Model: "+Class$
		'Print "~n"
		Radar.Radar()
		Thruster.Thruster()
		Drone.Drone()
	End Method

End Type

Type NT_Scout_A Extends NT_ship
	Function Create:NT_Scout_A(_Name$)
		Local i:NT_Scout_A=New NT_Scout_A
		i.Radar=T_Component.Component_Radar
		i.Thruster=T_Component.Component_Blank
		i.Drone=T_Component.Component_Blank
		i.Name$=_Name$
		i.Class$="NT_Scout_A"
		i.ID
		Return i
	End Function
End Type

Type NT_Scout_B Extends NT_ship
	Function Create:NT_Ship(_Name$)
		Local i:NT_Scout_B=New NT_Scout_B
		i.Radar=T_Component.Component_Blank
		i.Thruster=T_Component.Component_Thruster
		i.Drone=T_Component.Component_Blank
		i.Name$=_Name$
		I.Class$="NT_Scout_B"
		i.ID
		Return i
	End Function
End Type

Type NT_Scout_C Extends NT_ship
	Function Create:NT_Ship(_Name$)
		Local i:NT_Scout_C=New NT_Scout_C
		i.Radar=T_Component.Component_Blank
		i.Thruster=T_Component.Component_Blank
		i.Drone=T_Component.Component_Drone
		i.Name$=_Name$
		I.Class$="NT_Scout_C"
		i.ID
		Return i
	End Function
End Type

Type NT_Scout_D Extends NT_ship
	Function Create:NT_Ship(_Name$)
		Local i:NT_Scout_D=New NT_Scout_D
		i.Radar=T_Component.Component_Radar
		i.Thruster=T_Component.Component_Thruster
		i.Drone=T_Component.Component_Blank
		i.Name$=_Name$
		I.Class$="NT_Scout_D"
		i.ID
		Return i
	End Function
End Type


Ship1:NT_Ship=NT_Ship.create("Basic")
Ship2:NT_Ship=NT_Scout_A.create("Ship 1")
Ship2:NT_Ship=NT_Scout_B.create("Ship 2")
Ship2:NT_Ship=NT_Scout_C.create("Ship 3")
Ship2:NT_Ship=NT_Scout_D.create("Ship 4")




had a little attempt at what you said would this be good working practice ?