public void main ( ) {
String coachesWords = My width is ; Number coachesWidth = 0 ; String widthAsString = default string ; String extendedString = default string ; |
|
// Copyright 2007 R.G.Baldwin |
// Program demonstrates the use of variables. |
doInOrder { |
|
// Coach reports his current width without using variables |
// and turns once. |
doInOrder { . . . } |
|
// Statement taken from program Alice0135a. |
coach .say( ( My width is + ( ( subject = coach .getWidth() ) .toString() ) ) ); duration = 3 seconds |
coach .turn( RIGHT , 1 revolution ); |
} |
// 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 |
} |
} |
} |
} |