java lab 18

CPS 150 Lab Project 18: The Drunkard’s Walk (Java Loops)

This lab project is due on Wednesday, March 29, 2017 at 12:00 PM

A drunkard in a grid of streets randomly picks one of four directions and stumbles to the next intersection, then again randomly picks one of four directions, and so on. You might think that on average the drunkard doesn’t move very far because the choices cancel each other out, but that is actually not the case.

Starting with the NB_Grafix_Thing2 project, add Java code to the paint method so that it will graphically display the drunkard's walk, using the following algorithm:
 

java lab 18 1

Notes:

the canvas dimensions are 800 x 572, so the center point is at (400, 286)

Optional:

draw each step of the drunkard's walk in a random color






Sample Runs:


java lab 18 2


java lab 18 3

What Do I Hand In?

Once you are done, upload the completed source code file (i.e., NB_Grafix_Thing2.java).