TestScenario2.java



/** BananaWorld の出来事の実験(その2) */

package bananaworld;

public class TestScenario2 {

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

       BananaTree tree = new BananaTree();
       Elephant elephants[] = new Elephant[3];
       Snake snake = new Snake();

       for( int i=0; i<elephants.length; i++ ) {
           elephants[i] = new Elephant();

           Banana[] bananaArray = tree.drop();
           for( int j=0; j<bananaArray.length; j++ ) {
               elephants[i].eat( bananaArray[j] );
           }
           snake.eat( elephants[i] );
       }

       System.out.println( "Snake Energy is "
                          + snake.getEnergy() );
   }
}