Combined
Up until now you’ve written two lines of code to light both eyes up in color.
Look at the example on the left!
In this example we get to know a new method:
bob3.setEyes(color1, color2);
This method allows us to turn on both eyes in color with a single line of code.
Our new methodbob3.setEyes(color1, color2);
has two parameters:
color1
and color2
We replace the text color1
with the uppercase color name that eye 1 should have, e.g. WHITE
We replace the text color2
with the uppercase color name that eye 2 should have, e.g. ORANGE
We can replace the code in lines 8 and 9 with the statement
bob3.setEyes(WHITE, ORANGE);
Try it out!
Test your new program on your BOB3.
Change the code so that
eye 1 lights blue and eye 2 in yellow!
eye 1 lights blue and eye 2 in yellow!
Compile and test your program on BOB3.