Source code for the program named Alice0145b

The source code for the program named Alice0145b is presented in Listing 2.

Listing 2. Source code for program named Alice0145b.

Alice0145b's Code

Created by: Dick Baldwin

world

Methods

  public void main ( ) {
    
       // Copyright 2007, R.G.Baldwin
  // Demonstrates world-level methods with parameters.
  // Set the stage, could make invisible.
  doTogether { . . . . . . }
       // Position the camera.
  doTogether { . . . . . . }
       camera .setPointOfView( world ); duration = 0 seconds
  camera .turn( LEFT , 0.5 revolutions ); duration = 0 seconds
  camera .move( BACKWARD , 10 meters ); duration = 0 seconds
  camera .move( UP , 2 meters ); duration = 0 seconds
  camera .move( RIGHT , 4 meters ); duration = 0 seconds
  camera .pointAt( penguin2.head ); duration = 0 seconds
  }
  // Position the penguins.
  doTogether { . . . . . }
       penguin1 .setPointOfView( world ); duration = 0 seconds
  penguin2 .setPointOfView( world ); duration = 0 seconds
  penguin3 .setPointOfView( world ); duration = 0 seconds
  penguin1 .move( RIGHT , 1 meter ); duration = 0 seconds
  penguin3 .move( LEFT , 1 meter ); duration = 0 seconds
  }
  // Resize and position the cows.
  doTogether { . . . . . . . . . . . }
       cow1 .resize( 0.8 ); duration = 0 seconds
  cow2 .resize( 0.8 ); duration = 0 seconds
  cow3 .resize( 0.8 ); duration = 0 seconds
  cow1 .setPointOfView( world ); duration = 0 seconds
  cow2 .setPointOfView( world ); duration = 0 seconds
  cow3 .setPointOfView( world ); duration = 0 seconds
  cow1 .move( RIGHT , 1 meter ); duration = 0 seconds
  cow3 .move( LEFT , 1 meter ); duration = 0 seconds
  cow1 .move( BACKWARD , 2 meters ); duration = 0 seconds
  cow2 .move( BACKWARD , 2 meters ); duration = 0 seconds
  cow3 .move( BACKWARD , 2 meters ); duration = 0 seconds
  }
  }
  // Do the drill.
  doInOrder {
       wait( 1 second );
  doTogether { . . . . . . }
       world.closeOrderDrill ( theObject = penguin1 , direction = RIGHT , distance = 2 );
  world.closeOrderDrill ( theObject = penguin2 , direction = RIGHT , distance = 2 );
  world.closeOrderDrill ( theObject = penguin3 , direction = RIGHT , distance = 2 );
  world.closeOrderDrill ( theObject = cow1 , direction = LEFT , distance = 1 );
  world.closeOrderDrill ( theObject = cow2 , direction = LEFT , distance = 1 );
  world.closeOrderDrill ( theObject = cow3 , direction = LEFT , distance = 1 );
  }
  }
  }


  public void closeOrderDrill ( Object theObject, Direction direction, Number distance) {
    
       // Demonstrates world-level method with parameter.
  // Specific behavior is based on parameter values.
  // Do same movement four times in succession.
  // Note: Haven't studied the use of loops yet.
  doInOrder { . . }
       theObject .turn( direction , 0.25 revolutions );
  theObject .move( FORWARD , distance meters );
  }
  doInOrder { . . }
       theObject .turn( direction , 0.25 revolutions );
  theObject .move( FORWARD , distance meters );
  }
  doInOrder { . . }
       theObject .turn( direction , 0.25 revolutions );
  theObject .move( FORWARD , distance meters );
  }
  doInOrder { . . }
       theObject .turn( direction , 0.25 revolutions );
  theObject .move( FORWARD , distance meters );
  }
  }