Lab: Talking Robot

Using If-Else and Random Numbers


This lab should be done individually. It is okay to get help from the TAs and/or the instructor if you get stuck, but you should try to do it on your own first.

Tip: You should get into the habit of making backup copies of your work.


Some of the hot toys lately have been robots. Consider one particular robot that can walk and talk. Its "conversation" consists of uttering one of several phrases chosen at random, such as "Hey, how's it going?" or "You look marvelous!"

Improved Choice of Phrases based on Time of Day:

Suppose the robot can read a clock.

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 phrases depend on the time of day. For example, if it's before 10 am, it might say "Good morning!", "This is way too early for me!", or "Hey, how's it going?" If it's close to lunch time, it might say, "I'm hungry. Let's go eat lunch.", "I'm never going to finish my homework before class!", or "You look marvelous!"

Specifications:

Design: Before starting to implement your talking robot, take a few minutes to plan which time blocks you are going to use and identify at least one phrase for each time block. You might write these out as a table.

Time Block2 - 4 Possible Phrases for Time Block
  
 
  
 
  
 
  
 

Implementation: A good software development practice is to start by writing the smallest amount of code that you can test, test it, then continuing by adding small, incremental changes and testing all along the way. (This is sometimes known as Iterative, Incremental Development or "always have working code.")


When you complete the lab, you can start work on Programming Project #2 (due at the beginning of Lab 3).