Question: Java program for simple robot that walks randomly. Part 4 and 5 are related to this question. 3. A simple robot that walks randomly Let's

Java program for simple robot that walks randomly.
Part 4 and 5 are related to this question.
 Java program for simple robot that walks randomly. Part 4 and
5 are related to this question. 3. A simple robot that walks
randomly Let's have some fun. Let's design and implement a simple robot

3. A simple robot that walks randomly Let's have some fun. Let's design and implement a simple robot to model a random walk. We will then write two client programs that use it for two different things. A random walk is basically a sequence of steps in some (possibly enclosed) space where the direction of each step is random. The walk terminates when a maximum number of steps has taken place or when the random walker steps outside of the space. Random walks can be used to simulate things like the movement of molecules and economic phenomena like stock prices. We will assume our RandomWalker is walking on a two dimension square grid. In fact, let's assume our simulations takes place on a square grid with the point (0,0) at the center. The boundary of the square will be a single integer that represents the maximum x- and y- coordinate for the current position on the square (so for a boundary value of 10, both the x- and y-coordinates can vary from -10 to 10, inclusive). Each step will be one unit up, one unit down, one unit to the left, or one unit to the right. (No diagonal movement.) 1. Create a new class called RandomWalker. It should have the following instance variables i. The x coordinate of the current position 3 of 6 COMP 1510 Bruce Link, Keith Tang, Patrick Guichon, leffrey Yim, Chris Thompson ii. The y-coordinate of the current position ii. The maximum number of steps in the walk iv. The current number of steps taken v. The boundary of the square the walker inhabits 2. The RandomWalker has an overloaded constructor. There is more than one constructor i. The first version accepts two integers and assigns the first to the maximum number of steps in the walk, the second to the boundary, and sets the other instance variables to zereo The second version accepts four integers representing the maximum number of stps in the walk, the x-coordinate, the y-coordinate, and the boundary, and assigns these to the corresponding instance variables. The other instance variable should be set to zero, ii. 3. The RandomWalker has a toString that prints out the coordinates and the current step number 4. Create a driver class called TestWalker which contains a main method i. Declare and instantiate a RandomWalker with maximum steps 10 in a square of boundary size 5 (so a square that's 11 x 11 with the RandomWalker in the middle) li. Ask the user for values for maximum steps and boundary size and create a second RandomWalker using those values ii. Print out the tostring information for each RandomWalker object. How does

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!