Conceptual OOP Question - AArgh!

BlitzMax Forums/BlitzMax Beginners Area/Conceptual OOP Question - AArgh!

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.

something like this may work





Type TCarriage
	Field name:String
	Field x:Int  , y:Int
	Field weight:Int
	Field link:TLink
	Method move()
		' move the train here. called from TTrain type
	End Method
	
	Method display()
		' this is called from TTrain type
		Print name
	End Method

End Type

		
Type TTrain
	Field name:String
	Field conductor:String
	Field car_list:Tlist
	
	Method move()
	
	End Method
	
	Method add_Carriage(carname:String)
		Local temp:TCarriage = New TCarriage
		temp.name = carname
		
		temp.link = ListAddLast(car_list,temp)		' add this carriage to the list and save our tlink for later
		
	End Method
	
	Method Remove_Carriage(carname:String)
		For Local S:TCarriage = EachIn car_list
			If s.name = carname
				RemoveLink s.link			' scans the list and removes by link (you can use this to remove the 
			EndIf						' carriage based on different properties...
		Next

		
	End Method

	Method display()
		Print "you are on the "+name
		Print "You're conductor today is "+conductor
		
		Print "we are pulling:"
		
		For Local S:TCarriage = EachIn car_list
			s.display()
		
		Next
	
	End Method
	
	
End Type

Diesel:TTRAIN = New TTRAIN
diesel.name = "Silver Bullet"
diesel.conductor = "Ant"
diesel.car_list = CreateList()


diesel.add_carriage("Engine")
diesel.add_carriage("Coal Car")
diesel.add_carriage("Passenger Car")
diesel.add_carriage("Lumber Car")
diesel.add_carriage("Caboose")

diesel.display()

Print
Print 	"let's remove the Passenger car"
Print 
diesel.Remove_Carriage("Passenger Car")
diesel.display()