Question about Objects

BlitzMax Forums/BlitzMax Beginners Area/Question about Objects

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.

Well since your code doesn't compile in a meaningful way, here is an example of using polymorphism to solve this problem:
Strict

Type Gun
	Field name:String
	
	Method New()
		name = "an unspecified gun"
	EndMethod
EndType

Type MP5 Extends Gun
	Method New()
		name = "an awesome H&K MP5"
	EndMethod
EndType

Type UMP Extends Gun
	Method New()
		name = "a worthless POS"
	EndMethod
EndType

Local weap:String

While weap.toLower() <> "quit"
	Print "Type 'quit' to quit"
	weap = Input ("Which weapon, MP5 or UMP? ")
	Local MyGun:Gun

	Select Weap.toLower()
		Case "mp5"
			MyGun = New MP5;
		Case "ump"
			MyGun = New UMP;
		Default
			MyGun = New Gun;
	EndSelect
	
	Print "You chose "+MyGun.name
endwhile
End