Elle B.

asked • 01/09/23

How to make object move 3 steps ahead randomly in any direction (JAVA)


The following code allows for a "bird" to move one step on GUI in any random direction. How do you make the bird move 3 steps ahead at once randomly in any direction?


double r = Math.random();

if (r < 0.25)

return NORTH;

else if (r < 0.5)

return SOUTH;

else if (r < 0.75)

return EAST;

else

return WEST;

}


Thank you for help in advance.

Judy R.

Hello I am 22 years experienced Online Tutor and Assignment Helper for Computer Science and Math. I have been teaching IT Professionals, students from different grades, and Graduate and Post Graduate students for more than 22 years. I am ready to help you with your learning requirements, assignments, tests, and projects. For further discussion about the assignment or project help you need, please add me on skype and my skype id is nettuitions Thanks
Report

01/22/23

2 Answers By Expert Tutors

By:

Judy R. answered • 01/22/23

Tutor
New to Wyzant

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.