-1
Ich schreibe ein Java-Programm, in dem ich die Schildkröte bewegen müssen, um West, Ost, Nord und Süd zu bewegen, aber was ich bisher habe nicht die Schildkröte zu bewegen in der gewünschten Richtung.Mein Programm sagt Compiler Fehler nach der Einstufung in Gitbash
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);
}
}
Warum haben Sie eine moveTurtleTo() -Methode innerhalb einer Methode namens moveTurtleTo()? zeigen Sie Ihre überladene Methode und zeigen Sie die Turtle-Klasse – abcOfJavaAndCPP
Compiler-Fehler unterscheiden sich von unerwünschtem Verhalten. Könnten Sie bitte die Kompilierungsfehler veröffentlichen? – efekctive
wie soll es bitte sein? – oneirion