Talking Robot Programming Project


 

For this project you will implementing a variation of the Robot class in the Talking Robot Lab.

Question/Answer Version:

The robot is operated by a remote control. Two buttons on the remote control represent asking the robot a question and getting the answer. If you press the first button, the robot asks, "What is your question?" If you press the second button, the robot gives a randomly chosen "answer" to the question, such as "Definitely!", "OK", or "No way!"

You have been hired by the makers of the robot to help create a new and improved version. Your focus will be to improve its conversational skills by making its choice of answers depend on the actual question asked. The robot will not be able to answer all possible questions (which would be very tough to do!), but it will be able to recognize a small number of predefined questions, like "What would you like for lunch?", and be able to give a variety of randomly-chosen answers for each question. You will have to write your answers to the console, since you don't have an actual robot to program.

Another employee is writing some voice recognition software that will figure out which of the predefined questions has been asked. The VoiceRecognition class that they are writing will have a getQuestion method. This method can be used to determine (recognize) what question has been asked. It will return a String, whose contents are the question. The method is defined as

public String getQuestion()

The set of possible questions that it will recognize are:
  1. What would you like for lunch?
  2. What game do you want to play?
  3. Will I get my homework done on time?
  4. What is the weather going to be like today?
  5. What should we do this weekend?
The voice recognition software cannot recognize anything other than these five questions. So the getQuestion method will either return one of these 5 questions, or a null reference when it does not understand the question.

To begin, download the Talking Robot program. The code you add should go into the main method of the Robot2.java file in the Code folder.

Your program should construct a VoiceRecognition object and then ask it to get a question. Once you have the question returned by the VoiceRecognition object, get a random number and use it to decide which answer to print. When you first start writing your program, though, you might just want to check the question and always give the same answer for that particular question. Once you have the code written to your satisfaction, you can replace the single answer with a block of code that prints one of several randomly-chosen answers. Your code should print out the question asked, as well as the answer given.

Finally, to simulate having a conversation with the robot, modify your code so that it will go through the get-a-question, give-an-answer sequence a number of times (at least 4 or 5).

Be sure that you have updated the class documentation at the top of the file and that your program conforms to the style and documentation standards for this class. The class documentation comments should describe the purpose and behavior of your main class from a user's perspective. Focus on what the program does, rather than how it does it. Include your name and the date as well as the names of anyone from whom you received help. Following the style and documentation standards is an important step towards writing well-structured and reusable programs.