Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util. * ; import java.awt. * ; public class DancingTurtles { public static void main ( String [ ] args ) { World world

import java.util.*;
import java.awt.*;
public class DancingTurtles
{
public static void main(String[] args)
{
World world = new World(500,400);
Turtle yertle = new Turtle(world);
// This is a loop that runs 10 times (you will learn to write loops in Unit 4)
for(int i=1; i <=10; i++)
{
// Can you choose a randomX between 0-500?
// Can you adjust for the 20 pixel width of the turtle,
// so it doesn't get cut off at the edges?
// Move the range from 20 to 480.
int randomX =
// Can you choose a randomY between 0-400?
// Can you adjust for the 20 pixel height of the turtle,
// so it doesn't get cut off at the edges?
int randomY =
yertle.moveTo(randomX, randomY);
yertle.turnRight();
// Can you choose a random red, green, and blue value between 0-255?
int randomR =
int randomG =
int randomB =
yertle.setColor(new Color(randomR, randomG, randomB));
}// end of loop
world.show(true);
}
}

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

More Books

Students also viewed these Databases questions