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

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

View Full Document Right Arrow Icon
// *********************************************************** // 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();
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: System.out.print ("Enter the starting x and y coordinates with a space between: "); x = scan.nextInt(); y = scan.nextInt(); walk1 = new RandomWalk(10,5); walk2 = new RandomWalk(maxSteps, maxCoord, x, y); for (int i=0; i<5; i++) { walk1.takeStep(); System.out.println("walk1: " + walk1); walk2.takeStep(); System.out.println("walk2: " + walk2 + "\n"); } RandomWalk walk3 = new RandomWalk(200, 10); walk3.walk(); System.out.println("walk3: "+ walk3); System.out.println("\n** Max Distances **"); System.out.println("walk1: " + walk1.maxDistance()); System.out.println("walk2: " + walk2.maxDistance()); System.out.println("walk3: " + 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