Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need Help finishing Code! Seems like I am missing some steps please Help! Step 1. Implement the Walker class. The Walker only needs two pieces

Need Help finishing Code! Seems like I am missing some steps please Help!

image text in transcribed

image text in transcribed image text in transcribed

Step 1. Implement the Walker class. The Walker only needs two pieces of dataits x-location and its y-location. o In the constructor of the class, you need to initialize the location of the Walker to the center of the window. o Implement the display method. This method draws a black point as the Walker. o Implement the step method. This method directs the Walker to take a step. There are four possible steps. A step to the right can be simulated by incrementing x (x++); to the left by decrementing x (x--); forward by going down a pixel (y++); and backward by going up a pixel (y--). You need to use the random method to randomly pick from the above 4 choices and direct the Walker Step 2. In the main part of the sketch, create a Walker object in the setup method and display the trail of the Walker using the draw method. Step 3. Implement the Improved Walker class. NNA 4 possible steps 8 possible steps i class Walker 3 4 //field variables int x; int y; 5 6 //constructors 7 Walker() 8 { 9 width/2; height/2; 1} 2 // functions 3 void display() 4 { 5 stroke(0); 6 fill(255); 7 ellipse (x, y, 10, 10); int ri 9 0 void step) 1 { 2 3 r = (int) random(4); 4 5 if (r == 0) 6 X++; else if (r == 1) 8 X--; 9 else if (r == 2) y++; 1 else if (r == 3) 2 y--; 3 } Step 1. Implement the Walker class. The Walker only needs two pieces of dataits x-location and its y-location. o In the constructor of the class, you need to initialize the location of the Walker to the center of the window. o Implement the display method. This method draws a black point as the Walker. o Implement the step method. This method directs the Walker to take a step. There are four possible steps. A step to the right can be simulated by incrementing x (x++); to the left by decrementing x (x--); forward by going down a pixel (y++); and backward by going up a pixel (y--). You need to use the random method to randomly pick from the above 4 choices and direct the Walker Step 2. In the main part of the sketch, create a Walker object in the setup method and display the trail of the Walker using the draw method. Step 3. Implement the Improved Walker class. NNA 4 possible steps 8 possible steps i class Walker 3 4 //field variables int x; int y; 5 6 //constructors 7 Walker() 8 { 9 width/2; height/2; 1} 2 // functions 3 void display() 4 { 5 stroke(0); 6 fill(255); 7 ellipse (x, y, 10, 10); int ri 9 0 void step) 1 { 2 3 r = (int) random(4); 4 5 if (r == 0) 6 X++; else if (r == 1) 8 X--; 9 else if (r == 2) y++; 1 else if (r == 3) 2 y--; 3 }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

Students also viewed these Databases questions

Question

l Develop an organization chart using job families.

Answered: 1 week ago

Question

1 . Television News channels importantance of our Life pattern ?

Answered: 1 week ago

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago