TestWalk

# TestWalk - System.out.print&amp;quot;Enter the starting x and y coordinates with a space between&amp;quot x = scan.nextInt y = scan.nextInt

This preview shows page 1. Sign up to view the full content.

// *********************************************************** // TestWalk.java // // Program to test methods in the RandomWalk class. // *********************************************************** import java.util.Scanner; public class TestWalk { public static void main (String[] args) { int maxSteps; // maximum number of steps in a walk int maxCoord; // the maximum x and y coordinate int x, y; // starting x and y coordinates for a walk RandomWalk walk1, walk2; System.out.println ("\nRandom Walk Test Program"); System.out.println (); System.out.print ("Enter the maximum number of steps: "); maxSteps = scan.nextInt(); System.out.print ("Enter the boundary for the square: "); maxCoord = scan.nextInt();
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: System.out.print (&amp;quot;Enter the starting x and y coordinates with a space between: &amp;quot;); x = scan.nextInt(); y = scan.nextInt(); walk1 = new RandomWalk(10,5); walk2 = new RandomWalk(maxSteps, maxCoord, x, y); for (int i=0; i&amp;lt;5; i++) { walk1.takeStep(); System.out.println(&amp;quot;walk1: &amp;quot; + walk1); walk2.takeStep(); System.out.println(&amp;quot;walk2: &amp;quot; + walk2 + &amp;quot;\n&amp;quot;); } RandomWalk walk3 = new RandomWalk(200, 10); walk3.walk(); System.out.println(&amp;quot;walk3: &amp;quot;+ walk3); System.out.println(&amp;quot;\n** Max Distances **&amp;quot;); System.out.println(&amp;quot;walk1: &amp;quot; + walk1.maxDistance()); System.out.println(&amp;quot;walk2: &amp;quot; + walk2.maxDistance()); System.out.println(&amp;quot;walk3: &amp;quot; + walk3.maxDistance()); } }...
View Full Document

## This note was uploaded on 03/22/2010 for the course CS 202 taught by Professor Fong during the Spring '10 term at SIU Carbondale.

Ask a homework question - tutors are online