【发布时间】:2017-03-19 11:12:06
【问题描述】:
我正在编写一个 Java 程序,在该程序中我必须让乌龟向西、向东、向北和向南移动,但到目前为止我没有让乌龟向所需的方向移动。
public class Assignment7 {
// TODO - you need to implement this. Move the given turtle to the West, n times
public static void moveTurtleWest(Turtle t, int n)
{
}
// TODO - you need to implement this. Move the given turtle to the East, n times
public static void moveTurtleEast(Turtle t, int n)
{
for(int i=0; i <n;i++ ){
t.moveEast();
}
// TODO - you need to implement this. Move the given turtle to the North, n times
public static void moveTurtleNorth(Turtle t, int n)
{
for(int i=0; i <n;i++ ){
t.moveNorth();
}
// TODO - you need to implement this. Move the given turtle to the South, n times
public static void moveTurtleSouth(Turtle t, int n)
{
for(int i=0; i <n;i++ ){
t.moveSouth();
}
// TODO - you need to implement this. Move the turtle to the asked position, by calling MoveXXX etc
public static void moveTurtleTo(Turtle t, int x, int y)
{
moveTurtleTo(turtle.xPos,turtle.yPos);
}
public static void main(String[] args) {
// you can use this as you wish to test or exercise your function. Not graded.
Turtle t=new Turtle();
moveTurtleTo(t,15,16);
System.out.println(t);
}
}
【问题讨论】:
-
为什么你在一个名为 moveTurtleTo() 的方法中有一个 moveTurtleTo() 方法?显示你的重载方法并显示 Turtle 类
-
编译器错误与不良行为不同。能否请您发布编译错误?
-
请问应该怎么样?
-
FAILURE:构建失败并出现异常。 * 出了什么问题:任务 ':compileJava' 执行失败。 > 编译失败;有关详细信息,请参阅编译器错误输出。 * 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。构建失败总时间:1.684 秒
标签: java turtle-graphics