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!"

You have been hired by the makers of the robot to help create a new and improved version with an internal clock. Your focus will be to improve its conversational skills by having it report on the time and 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!"

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


Reporting the Time of Day:

The first new piece of functionality for the robot is basically to print out a timestamp.

Improved Choice of Phrases based on Time of Day:

Specifications:

Design: Before starting to implement this aspect of 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:


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