Zebra0.com

alice random

Download the alien number game.

public void myFirstMethod() {
    Integer myNumber = RandomUtilities.nextIntegerFromAToBInclusive( 1, 100 );
    this.alien.say( "I'm thinking of a number from 1 to 100.", Say.duration( 10.0 ) );
    Integer guess = this.alien.getIntegerFromUser( "What is your first guess?" );
    while ( guess! = myNumber ) {
        if( guess<myNumber ) {
            this.alien.say( "My number is more than "+guess, Say.duration( 2.0 ) );
        } else {
            this.alien.say( "My number is less than "+guess, Say.duration( 2.0 ) );
        }
        guess = this.alien.getIntegerFromUser( "What is your next guess?" );
    }
    this.alien.say( "You finally guessed it!" );
} 

Run the program, then modify as below.

End of lesson, Next lesson: