CMSC 160 -- Lab 9

Lab 9

Getting Started

Log into the computer science server and use wget and tar to download your starter code.
  1. Use wget to download the file at http://cs.longwood.edu/courses/cmsc160/f17/files/lab9.tgz
  2. Uncompress the lab9.tgz file by using tar -xvzf lab9.tgz
  3. Use ls to see that there is a new directory called lab9
  4. Use cd lab9 to change directory to the lab9 directory


The Problem

A student at Poedunk University has consumed too much root beer and is wandering the streets of Nowheresburgh city. The student travels exactly one city block (in a random direction) every minute. The streets of Nowheresburgh are in a perfect grid. We are going to write a program to track the student’s travels.

You will need to write the following structure:
Point
a point stores two integers x and y
You will need to write the following functions:
  1. randomStep
    input: nothing
    output: a random Point one of (-1,0) (0,-1) (1,0) (0,1)
  2. inLimits
    input: a Point location and a Point bounds
    output: returns true if the location is with the range of (0,0) to bounds
  3. addPoint
    input: a Point p and a Point q
    output: returns a Point representing p+q

Your program will read in two integers: the number of blocks and the number of steps.

The blocks variable will be used to determine the number of city blocks in Nowheresburgh. Our student will start in the middle of the city and there will be blocks number of city blocks to the north, south, east, and west. How big should your multi-dimensional vector be?

The steps variable describes how many minutes your program should simulate.

You will need to keep track of where the student is currently in the city and how many times they have visited each spot in the city. The student can’t leave the city limits, any direction which leaves the bounds will be ignored.

Remember, you will be graded on style, syntax, functionality, and correctness. Since our lab uses random numbers you will not need test cases.

You must use a Makefile. Please remember to submit a README.txt

This is not your friend’s work. This is not the internet’s work. This is your work...

Examples

10
250
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . 1 2 . . . . . . . . . . 
. . . . . . . . . 1 3 2 3 3 . . . . . . . 
. . . . . . . . . 2 3 5 5 1 1 . . . . . . 
. . . . . . . 1 2 2 3 7 8 3 4 . . 2 2 . . 
. . . . . . . 1 3 2 3 3 4 6 8 2 4 3 2 . . 
. . . . . . . 1 2 1 2 2 3 4 8 7 6 3 3 . . 
. . . . . . . 1 1 . . . 1 3 4 5 3 . 1 . . 
. . . . . . . . 1 1 . . . 2 2 5 1 . . . . 
. . . . . . . . . 1 . . . 2 2 4 1 . . . . 
. . . . . . . . . 3 3 . . 2 2 . . . . . . 
. . . . . . . . . 2 4 1 . . . . . . . . . 
. . . . . . . . 2 3 5 3 2 1 . . . . . . . 
. . . . . . . . . 3 9 1 . . . . . . . . . 
. . . . . . . . . 4 7 3 . . . . . . . . . 
10
300
4 6 1 . . . . . . . . . . . . . . . . . . 
1 2 1 . . . . . . . . . . . . . . . . . . 
1 5 4 . . . . . . . . . . . . . . . . . . 
1 3 2 1 1 . . . 1 1 3 . . . . . . . . . . 
. 2 1 . 1 1 2 1 2 2 3 . . . . . . . . . . 
. . . . . 2 4 5 4 2 1 1 1 . . . . . . . . 
. . . . 1 3 . . . . . . 1 1 . . . . 1 . . 
. . . 1 2 2 . . . . . . 1 1 . . . . 2 1 . 
. . . . 3 3 . . . . 2 2 3 . . . . 1 2 2 . 
. . . 1 3 1 . . . 3 7 3 4 2 . . . . 2 7 2 
. . . . 1 . . . . 2 4 3 6 5 1 1 1 1 3 6 1 
. . . . . . . . . . 2 3 2 2 2 2 1 . 1 2 5 
. . . . . . . . . . 1 1 . 1 2 2 . . 2 5 8 
. . . . . . . . . . . . . 1 2 5 1 . 2 8 6 
. . . . . . . . . . 1 . . 1 2 6 2 . . 5 6 
. . . . . . . . . . 2 3 4 2 1 1 1 . . 1 2 
. . . . . . . . . . . . 2 1 . . 1 2 1 1 . 
. . . . . . . . . . . . . . . . . 2 . . . 
. . . . . . . . . . . . . . . . . 2 1 . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . .
10
200
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . 1 . . . . . . 
. . . . . . . 1 1 . . 1 1 . 3 1 1 1 . . . 
. . . . . . . 3 4 4 6 4 2 1 3 3 3 2 1 . . 
. . . . . 1 2 5 2 2 7 5 1 . . . 3 3 3 2 . 
. . . . 1 3 1 3 2 3 7 9 5 1 1 2 3 . . . . 
. . . . 1 3 2 3 8 8 4 7 6 2 2 3 3 . . . . 
. . . . 1 2 3 5 7 5 . . . . . . . . . . . 
. . . . . . . 1 . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . .
10
250
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . 
. . . . . . . 2 2 1 . . . . . . . . . . . 
. . . . . . 1 1 . 2 . . . . . . . . . . . 
. . . . . . 1 . 1 4 1 1 . . . . . . . . . 
. . . . . . 1 1 1 3 4 4 4 1 . . . . . . . 
. . . . . . . . . 3 6 5 8 3 . . . . . . . 
. . . . . . . . . 3 5 2 3 2 1 . . . . . . 
. . . . . . . . . . . . . . 1 1 2 5 4 3 1 
. . . . . . . . . . . . . . . . 5 7 3 4 3 
. . . . . . . . . . . . 1 3 4 7 6 3 3 5 5 
. . . . . . . . . . . . 2 6 5 2 1 2 2 2 2 
. . . . . . . . . . . . . 2 4 1 . 1 1 1 . 
. . . . . . . . . . . . . 1 1 . . 2 1 . . 
. . . . . . . . . . . . . . 3 3 2 1 . . . 
. . . . . . . . . . . . . . 1 2 3 1 1 . . 
. . . . . . . . . . . . . . . . 2 5 3 . . 
. . . . . . . . . . . . . . . . 3 6 5 1 . 
. . . . . . . . . . . . . . . . 3 5 7 1 .


Handin

When you are done you may hand in your lab by using make handin.

The lab is due at 11:59pm Oct. 31th 2017.