Zoo.java



/** 動物園の動物の情報
 *  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 pan[] = new Panda[2];
        pan[0] = new Panda( "Wakwak", 3 );
        pan[1] = new Panda( "Hokhok", 3 );

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

        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 +"." );
    }
}