【发布时间】:2018-12-11 12:56:45
【问题描述】:
我正在尝试在 Dr. Java 中完成一个 Turtle 项目,该项目有多个房间有问题需要推进,但我似乎无法找到并修复我遇到的错误。
这是我的代码:
0
import java.awt.*;
public class TurtleDrawing
{
public static void main(String args[])
{
boolean one = roomOne();
}
public static boolean roomOne();
{
World wor = new World(500,500);
Turtle turOne = new Turtle(0,0, wor);
Picture picOne = new Picture("grocery.jpg");
Picture pitTwo = new Picture("anteater.webp");
turOne.penUp();
turone.moveTo(200,200);
turOne.drop(picOne);
turOne.moveTo(300,100);
turOne.drop(picTwo);
turOne.hide();
turOne.forward(1);
JOptionPane.showMessageDialog(null, "Dequavis the anteater is shopping for
bananas at his local grocery store");
String str = JOptionPane.showImputDialog(null, "If each bundle costs 3
dollars and he buys 2 bundles how much will he pay?");
if (str.equals("6"))
return true;
else return false;
}
World wor = new World(1100,800);
Turtle turOne = new Turtle(wor);
turOne.penUp();
Picture picOne = new Picture ("space.jpg");
turOne.moveTo(0,0);
turOne.drop (picOne);
Turtle turTwo = new Turtle(wor);
turTwo.penUp();
Picture picTwo = new Picture ("rocket.png");
turTwo.moveTo(200,500);
turTwo.drop (picTwo);
turTwo.forward(1);
Turtle turThree = new Turtle(wor);
turThree.penUp();
Picture picThree = new Picture ("unircorn.png");
turTwo.moveTo(700,600);
turThree.drop (picThree);
turThree.forward(1);
Turtle turFour = new Turtle(wor);
turFour.penUp();
Picture picFour = new Picture ("spongebob.png");
turTwo.moveTo(400,600);
turFour.drop (picFour);
turFour.forward(1);
turOne.penUp();
double x = 0 ;
double y = 0;
int t = 0;
turOne.setColor(Color.BLUE);
while (t < 200)
{
if(t > 0)
turOne.penDown();
x = (16 * Math.sin(t)* Math.sin(t) * Math.sin(t))* -1 + 500 ;
y = (13 * Math.cos(t) - 5 * Math.cos (2 * t) - 2 * Math.cos(3 * t))-
Math.cos(4 * t) * -10 + 400;
t = t + 1;
turOne.moveTo((int)x, (int)y);
}
}
public static void heart( Turtle turOne , int startX, int startY)
{
double x = 0;
double y = 0;
int t = 0;
turOne.penUp();
if( t % 3 == 1)
turOne.setColor(Color.PINK);
if( t % 3 == 2)
}
}
我尝试过从多个人那里获得帮助,但我似乎无法解决问题。
【问题讨论】:
-
什么样的错误?编译错误?运行时错误?你得到什么错误?还是出了什么问题?
-
请添加您的堆栈跟踪。此外,粗略一看,其中一个错误可能是
turone.moveTo(200,200);,应该是turOne.moveTo(200,200); -
请阅读Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - 总结是这不是解决志愿者的理想方式,并且可能会适得其反。请不要将此添加到您的问题中。
标签: java turtle-graphics