Understanding your robot code

The comments (2), class name (3), method header (4) and curly brackets are all the same as in the regular Java program (Hello World) that did not communicate with the robot.

  1. Java does not know how to talk to your robot.
    All robots are different.
    This is the statement to give Java the ability to communicate with a Finch robot
  2. Comments
  3. Class name
  4. Starting standard method
  5. Before you can talk to a Finch you must give it a name
    This is called instantiating the robot
    Finch ___ = new Finch();
    is always the first thing to do in a Finch robot program.
  6. When you want the robot to do something, you refer to it by name and give it a command.
    The saySomething command will send a message from the robot to the computer speakers to try to speak the words in the quotes.
    If you don't hear anything, be sure your computer speakers are turned on!
  7. To prevent the program from ending immediately, before the robot has a chance to finish talking, tell the robot to wait.
    The sleep command tells the robot to wait a certain number of milliseconds (1000 milliseconds = 1 second)
  8. The robot works better if you specifically tell it to quit and then tell the program to exit.
    These aren't necessary, but they make it easier to keep the robot running from one program to another.

How well do you understand this code?

Answer carefully. Remember that upper and lower case make a difference in Java.

  1. What is the name of this class?
  2. What is the name of the method that the robot code is in?
  3. What is the name of this Finch?
  4. Write the complete line of code needed to create a different Finch robot named bob.
    (don't forget the semicolon at the end of the statement)
  5. What is the name of the method that tells the robot to say words out loud?
  6. What words does the robot say?
    (don't type in the quotes)
  7. Where are the speakers that the robot uses when it talks?
    a) in the robot's beak
    b) in the USB cable
    c) in the computer
  8. How long does the robot wait after being given the command to say something before ending the program?
    a) 15 seconds
    b) one and a half seconds
    c) 150 seconds
  9. What is the method that tells the robot to wait for a certain amount of time?
  10. What is the method that tells the robot to stop running its program?