Solution's Code

Created by: Barbara Lerner

world

Methods

  public void my_first_method ( ) {
    Boolean lunchLadySpeaks = true ;
       wait( 1 second );
  // Pick a person randomly to speak first.
  lunchLadySpeaks .set( value , ( Random.nextBoolean() 0.5 (50%) ) );
  if ( lunchLadySpeaks ) {
       LunchLady .say( I'd rather be in the cafeteria! ); duration = 2 seconds
  } else {
    Nerd .say( Just so you know... I've been practicing! ); duration = 2 seconds
  }
  // The dribbling contest
  doTogether {
       doInOrder {
       // Lunch lady dribbles successfully 9 times.
  for (int index=0; index< 9 times ; index++) {
       world.dribble ( whichHand = basketballAtLunchLady , whichBasketball = basketball );
  }
  // Lunch lady hits her foot with the ball.
  basketball .moveTo( basketballAtFoot ); style = BEGIN_GENTLY_AND_END_ABRUPTLY
  basketball .move( FORWARD , 5 meters );
  }
  // Nerd dribbles successfully 11 times.
  for (int index=0; index< 11 times ; index++) {
       world.dribble ( whichHand = basketballAtNerd , whichBasketball = basketball2 );
  }
  }
  // Nerd gets wise.
  Nerd .say( I'm number 1! ); duration = 2 seconds
  }


  public void dribble ( Object whichHand, Object whichBasketball) {
    Number distanceToFloor = 1 ;
       // Calculate the distance the ball should move to get to the floor.
  distanceToFloor .set( value , ( whichBasketball .distanceAbove( ground ) ) );
  // Bounce the ball.
  whichBasketball .move( DOWN , distanceToFloor meters ); style = BEGIN_GENTLY_AND_END_ABRUPTLY
  whichBasketball .moveTo( whichHand ); style = BEGIN_ABRUPTLY_AND_END_GENTLY
  }