CPS 6: Group Project #6

October 5, 1995

If you have any new members in your group today, introduce yourselves. One person should be designated the scribe (someone who wasn't the scribe last time). This assignment should be written down on one sheet of paper. Print the number of your group and the name of each group member participating at the top of the sheet.


Frog Hopping

You have been given a listing of the RandomWalk class and a main function that uses this class to simulate a one-dimensional random walk.

You are to determine how to modify the class so that the frog walks in two-dimensions, but is constrained to travel along grid points, i.e., only in directions North, South, East, and West. As a first step, you'll need to change the private data member myPosition to two data members: one for north-south (y) position and one for east-west (x) position. Name these two integer data members appropriately.

Then decide how the function TakeStep() will change so that the frog jumps (with equal probability) in one of the compass-point directions (hint: use a four sided die).

You should look carefully at other member functions and decide which ones will need to be modified to reflect the changes in how the frog walks. In particular, you'll need to change the member funtion GetPosition and how it is used. It currently returns one int representing the frog's final position. You'll need to change this so that two values are returned: both an x and y location. Decide how to do this and how the code in main must be altered to reflect the change.

Finally, determine what private data members and what member functions can be added to determine the furthest point from the origin that the frog walks during his exciting sojourn.


Writeup

Your final writeup should include the new private section of the class (at least the new data members) and a description of what member functions change and how they change. You should also include the prototype for GetPosition() and show how it is used in main.