Getting the distance to the chicken

Display Listing 2.

Open the functions tab for the coach object. 

Drag the function named distanceTo from the functions tab and drop it on top of the 1 that is showing as the return value in Figure 6.

Specify "the entire Chicken"

This produces code for the function named getDistanceToChicken that matches the source code for that function in Listing 2.

Listing 2. Source code for the program named Alice0135b.

Alice0135b's Code

Created by: Dick Baldwin

world

Methods

  public void main ( ) {
    
       // Copyright 2007 R.G.Baldwin
  // Program demonstrates defining a new function.
  doInOrder {
       print( ( Distance to chicken is: + ( ( coach.getDistanceToChicken ( ) ) .toString() ) ) );
  }
  }

coach

Functions

  java.lang.Number public Number getDistanceToChicken ( ) {
    
       // Get and return the distance to the chicken.
         return ( coach .distanceTo( Chicken ) ) ;
  }