/*
 * @topic T10332 Feb 5, 2013 Inheritance Demo v.1
 * @brief Main application class, InheritanceMain
*/
package inheritance;

public class InheritanceMain {

    public static void main(String[] args)
    {
        // This array represents a virtual world of cats and dogs:
        VWCharacter[] characters = new VWCharacter[ 10 ];

        int idx = 0;
        // Create some cats
        for ( ; idx < characters.length/2; ++idx ) {
            characters[ idx ] = new Cat( "buddy" + (idx + 1) );
        }

        // Create some dogs
        idx = characters.length/2;
        for ( ; idx < characters.length; ++idx ) {
            characters[ idx ] = new Dog( "barky" + (idx + 1) );
        }

        // Animate the world
        // *** UNEXPECTED RESULT:
        // java invokes the most specific version of the method,
        // regardless whether the method is declared abstract or not!
        // NOTE: This differs significantly from the C++ behavior!!
        idx = 0;
        for ( ; idx < characters.length; ++idx ) {
            characters[ idx ].speak();
        }
    }//main

}//class InheritanceMain