Listing 2. Source code for the program named Alice0140b.

Alice0140b's Code

Created by: Dick Baldwin

world

Methods

  public void main ( ) {
    String coachesWords = My width is ; Number coachesWidth = 0 ; String widthAsString = default string ; String extendedString = default string ; Number numberRevs = 5 ;
       // Copyright 2007 R.G.Baldwin
  // Program demonstrates the use of variables.
  // Also demonstrates user input.
  doInOrder {
       // Get number revs from user.
  numberRevs .set( value , ( NumberDialog( question = Enter number revolutions for coach ) ) );
  // Coach reports his current width without using variables
  // and turns numberRevs revolutions.
  doInOrder { . . . }
       // Statement taken from program Alice0135a.
  coach .say( ( My width is + ( ( subject = coach .getWidth() ) .toString() ) ) ); duration = 3 seconds
  coach .turn( RIGHT , numberRevs revolutions );
  }
  // Coach reports his current width using variables.
  doInOrder { . . . . . }
       coachesWords .set( value , My width is still );
  coachesWidth .set( value , ( subject = coach .getWidth() ) ); duration = 0 seconds
  widthAsString .set( value , ( coachesWidth .toString() ) ); duration = 0 seconds
  extendedString .set( value , ( coachesWords + widthAsString ) ); duration = 0 seconds
  coach .say( extendedString ); duration = 3 seconds
  }
  // Coach raises both arms and reports new width.
  doInOrder { . . }
       doTogether { . . }
       coach.upperBody.leftArm .roll( RIGHT , 0.25 revolutions );
  coach.upperBody.rightArm .roll( LEFT , 0.25 revolutions );
  }
  doInOrder { . . . . . }
       coachesWords .set( value , Now my new width is );
  coachesWidth .set( value , ( subject = coach .getWidth() ) ); duration = 0 seconds
  widthAsString .set( value , ( coachesWidth .toString() ) ); duration = 0 seconds
  extendedString .set( value , ( coachesWords + widthAsString ) ); duration = 0 seconds
  coach .say( extendedString ); duration = 3 seconds
  }
  }
  }
  }