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

Don Slater dslater at andrew.cmu.edu
Wed Jan 18 16:45:49 EST 2012


Schlomi,
In an earlier comment, someone noted that you were hoping to implement Polymorphism, and unfortunately Alice 2 was not designed to support that feature. It is an object based, not object oriented implementation of a language.

It was exactly for questions and problems such as these that the Alice Team started work on Alice 3, and we fully expect that Alice 3 will indeed allow polymorphism.

At the same time, it is an intriguing problem, and I am going to continue to see if there is some type of work around.

Thank you for your question, and all the best,

Don Slater


On Jan 15, 2012, at 7:30 AM, Shlomo Moshkovits wrote:

> 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.
> 
> ‎ _______________________________________________
> alice-teachers mailing list
> alice-teachers at lists.andrew.cmu.edu
> https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers



More information about the alice-teachers mailing list