Zebra0.com

alice booleanThe user is offered coffee and tea

The user is offered coffee and tea

See if you can add another choice


Text of video

Code:

public void myFirstMethod() {
     //Programmer : Janet Joy     
     //Pixie asks if you want coffee, tea, or soda.     
     Boolean answer = this.pixie.getBooleanFromUser( "Would you like coffee?" );
     if( answer ) {
       this.coffeeMaker.setOpacity( 1.0 );
     } else {
       //This code is only executed if answer about coffee is false.
	   answer = this.pixie.getBooleanFromUser( "Would like tea?" );
	   //answer is assigned a new value from the question about tea.
	   if( answer ) {
	      //This code is executed if they answer false to coffee and true to tea
		  this.teapot.setOpacity( 1.0 );
	   } else {
	      //This code is only executed if answer is false to both coffee and tea.
		  this.pixie.say( "Well, here is some soda." );
		  this.colaBottle.setOpacity( 1.0 );
	   }
   }  
 } 

Download this project

My code doesn't look like that!

NEXT: The seagull asks how many penguins there are.