Zebra0.com

alice arraysAnimals counting

Animals counting

An array of animals take turns to count


Download the Alice project: array-objects.a3p

public void myFirstMethod() {
    SJointedModel[] animals = new SJointedModel[] {
        this.yeti, this.tortoise, this.stuffedTiger
    }
    ;
    Integer counter = 0;
    while ( true ) {
        counter = counter+1;
        animals[counter%3].say( ""+counter );
    }
}  

NEXT: Birds spread wings and say something