Zoo.java



/** 象のデータの操作の実験のクラス @version 1.6
 *  配列を利用
 *  static なフィールドの情報も表示
 */
public class Zoo {

  /** 処理の開始 */
    public static void main( String[] argv ) {

        Elephant ele[] = new Elephant[4];
        ele[0] = new Elephant( "Hanako", 7 );
        ele[1] = new Elephant( "Tarou", 8 );
        ele[2] = new Elephant( "Gonta", 1 );
        ele[3] = new Elephant( "Yone", 90 );

        for( int i=0; i<4; i++ )
           System.out.println( ele[i].toString() );

        Panda pan1 = new Panda( "Wakwak", 3 );
        Panda pan2 = new Panda( "Hokhok", 3 );

        ElephantBoard eb[] = new ElephantBoard[4];
        for( int i=0; i<4; i++ )
             eb[i] = new ElephantBoard( ele[i] );

        System.out.println( pan1.toString() );
        System.out.println( pan2.toString() );

        PandaBoard pb1 = new PandaBoard( pan1 );
        PandaBoard pb2 = new PandaBoard( pan2 );

        System.out.println( "Number of Elephants in this Zoo is "
                           + Elephant.number +"." );
        System.out.println( "All Elephants in this Zoo are from "
                           + Elephant.origin +"." );
        System.out.println( "Number of Pandas in this Zoo is "
                           + Panda.number +"." );
        System.out.println( "All Pandas in this Zoo are from "
                           + Panda.origin +"." );
    }
}