alice-teacher How to call a customized method for an object that is passed as a parameter

Shlomo Moshkovits raam at bgu.ac.il
Sun Jan 15 07:30:34 EST 2012


Hi,

I am teaching my students on customized methods and just realized that  I can't call a customized method for an object I am passing as a parameter. I'd appreciate if someone could describe a workaround that will enable the following example:

1) In the world I create a method called moveAnimal(animal:Object) 
2) In the world I create 2 objects: dog1 and bird1
3) For each animal I create a method named animateMovement that either flaps the bird's wings or moves the dog's legs.

In moveAnimal(animal:Object) I want to be able to call the following an get a moving object that is animated differently depending on the type of the animal.
do together
{
   animal.animateMovement   //This is where I get the problem. Can't write such code.
   animal.move....                    
}
 

Thanks for the help.

Shlomi.

‎
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.andrew.cmu.edu/mailman/private/alice-teachers/attachments/20120115/deaac3b4/attachment.html 


More information about the alice-teachers mailing list