Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

When I run the following code, it brings up two errors regarding the lines for turtle 1 and turtule 2 when entering the coordinates, color,

When I run the following code, it brings up two errors regarding the lines for turtle1 and turtule2 when entering the coordinates, color, and size of the turtule. How would I fix this withot using world1 as the turtle's coordinates?
import java.util.*;
import java.awt.*;
public class CustomTurtleRunner
{
public static void main(String[] args)
{
World world1= new World(400,400);
//1. Change the constructor call below to create a large
//150x200 CustomTurtle with a green body (Color.green)
// and a blue shell (Color.blue) at position (150,300).
// Move it forward to see it.
CustomTurtle turtle1= new CustomTurtle(world1,Color.green,Color.blue,150,300);
turtle1.forward();
//2. Create a small 25x50 CustomTurtle with a red body
// and a yellow shell at position (350,200)
// Move it forward to see it.
CustomTurtle turtle2= new CustomTurtle(350,200, world1, Color.red, Color.yellow,25,50);
turtle2.forward();
//3. Create a CustomTurtle of your own design
CustomTurtle turtle3= new CustomTurtle(150,150, world1, Color.red, Color.pink, 75,100);
turtle3.setPenWidth(3);
turtle3.turnRight();
turtle3.forward();
turtle3.turnLeft();
turtle3.forward();
turtle3.turnLeft();
turtle3.forward();
turtle3.turnLeft();
turtle3.forward();
turtle3.turnRight();
turtle3.forward();
turtle3.turnRight();
turtle3.forward();
turtle3.turnRight();
turtle3.forward();
turtle3.turnLeft();
turtle3.forward();
turtle3.turnLeft();
turtle3.forward();
turtle3.turnLeft();
turtle3.forward();
turtle3.turnRight();
turtle3.forward();
turtle3.turnRight();
turtle3.forward();
turtle3.turnRight();
turtle3.forward();
turtle3.turnLeft();
turtle3.forward();
turtle3.turnLeft();
turtle3.forward();
turtle3.turnLeft();
turtle3.forward();
world1.show(true);
}
}
class CustomTurtle extends Turtle
{
private int x;
private int y;
private World w;
private Color bodycolor;
private Color shellcolor;
private int width;
private int height;
/** Constructor that takes the model display
* @param modelDisplay the thing that displays the model or world
*/
public CustomTurtle(ModelDisplay modelDisplay)
{
// let the parent constructor handle it
super(modelDisplay);
}
/** Constructor that takes the model
* display to draw it on and custom colors and size
* @param m the world
* @param body : the body color
* @param shell : the shell color
* @param w: width
* @param h: height
*/
public CustomTurtle(ModelDisplay m, Color body, Color shell, int w, int h)
{
// let the parent constructor handle it
super(m);
bodycolor = body;
setBodyColor(body);
shellcolor = shell;
setShellColor(shell);
height = h;
width = w;
setHeight(h);
setWidth(w);
}
}
/** Constructor that takes the x and y and a model
* display to draw it on and custom colors and size
* @param x the starting x position
* @param y the starting y position
* @param m the world
* @param body : the body color
* @param shell : the shell color
* @param w: width
* @param h: he
*/

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

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions

Question

Types of Interpersonal Relationships?

Answered: 1 week ago

Question

Self-Disclosure and Interpersonal Relationships?

Answered: 1 week ago