Running all Existing Classes in one command

Monkey Forums/Monkey Programming/Running all Existing Classes in one command

hardcoal(Posted 2012) [#1]
As Im new at monkey I have some noob quastions.

Is there a way to run all exsisting classes of all types in one command?

I mean that the engine will refer to the OnUpdate() Method
of every exsisting Class?

Im almost sure its not possible but maybe im wrong.


slenkar(Posted 2012) [#2]
to do that you could create an interface

Interface updateable
method update:Void()
End Interface

Class bicycle implements updateable
end class

Then every class you want to update you put on a list of updateables


local b:bicycle=new bicycle
local l:List<updateable>=new List<updateable>
l.AddLast(b)


for local u:updateable=eachin l
l.update()
next


hardcoal(Posted 2012) [#3]
Can you insert diffrent sorts of classes to this list and they will all be excuted?


hardcoal(Posted 2012) [#4]
Slenkar
I know its not the place but .. Are there equiliant commands in blitzmax


slenkar(Posted 2012) [#5]
q1-yes you can insert any class that implements updateable

q2- no, in blitzmax you have to use Extends, so you will have to create a class called updateable and then create classes like bicycle and car that Extend updateable -you can also do this in monkey


hardcoal(Posted 2012) [#6]
This is genius tnx for now


hardcoal(Posted 2012) [#7]
slenkar you really helped my i o you big time.

An advice to all.
I must say its worth asking questions and risking sounding silly
then trying to face stuff on your own


therevills(Posted 2012) [#8]
An advice to all.
I must say its worth asking questions and risking sounding silly
then trying to face stuff on your own


I would say you should do it the other way around:

Try to do it yourself, then if you get stuck or don't know how to continue then ask questions. And there are no silly questions apart from "Can I ask a question?", but make sure you can not find the answer yourself before asking others.


slenkar(Posted 2012) [#9]
youre welcome


hardcoal(Posted 2012) [#10]
hi therevills

I do try alot on my own before I ask
but still... consulting with people is the best thing.
but i cannot nag to people so 90% of stuff i face on my own.

cheers


ziggy(Posted 2012) [#11]
Questions are always welcome and may be of interest to other people facing the same situation.