1020: Introduction to Programming Winter 2014

Assignment 3

Due: February 10 at 12:00 noon

This assignment is to be done in pairs. Each pair of students should submit only one solution, but both names must be listed in the code.

In this assignment you will create four C++ functions that work together to respond to user input to drive the 3π. We have provided the following files:

To complete this assignment, download the above files as for previous assignments, and save them in the project directory. You must then create assign3.cpp. You will submit assign3.cpp only.

The functions you are to implement are as follows:

  1. void testMotion()
    This function should wait for one of the buttons (A, B, or C) to be pressed by calling the waitForAnyButton function and must cause the 3π to respond differently depending on which button was pressed, as follows:
    1. The 3π should turn 90 degrees counter-clockwise (to the left) by calling your turnLeft function.
    2. The 3π should drive ahead 1 foot by calling your driveAhead function.
    3. The 3π should turn 90 degrees clockwise (to the right) by calling yourturnRight function.
  2. void turnRight()
    Cause the 3π to turn on the spot 90 degrees to the right (clockwise). (This is the same function from A2 and you're welcome to reuse the same code here.)
  3. void turnLeft()
    Cause the 3π to turn on the spot 90 degrees to counter-clockwise.
  4. void driveAhead(double distance)
    A function to cause the 3π to drive straight ahead the given distance, in metres. Again, this is the same as in A2 so you can reuse your code.

After you have tested your program and are confident it is right, have a TA observe your robot functioning correctly and check you off, then submit assign3.cpp using websubmit.

Last modified $LastChangedDate: 2011-01-25 00:49:04 -0330 (Tue, 25 Jan 2011) $