Hallo zusammen, kann mir einer vielleicht erklären warum unten gezeigte Schleife, die eigentlich nur siebenmal durchlaufen werden soll 7 x7 mal läuft?
Das wäre sehr knorke, sonst brauch ich noch mehr Bier
Das wäre sehr knorke, sonst brauch ich noch mehr Bier
Java:
for (int j = 0; j < p.length; j++)
{
{
// System.out.println ("x = " + p[j].x);
//System.out.println("y =" + p[j].y);
int Startpunktx = 0;
int Startpunkty = 0;
for (int i = 0; i < p.length; i++)
{
System.out.println("Koordinatex=" + p[j].x);
System.out.println("Koordinatey=" + p[j].y);
if ((p[j].x - Startpunktx) > 0) {
for (int s = 0; s <= (p[j].x - Startpunktx) - 1; s++) {
moveEast();
}
} else if ((p[j].x - Startpunktx) < 0) {
for (int s = 0; s <= (p[j].x - Startpunktx) - 1; s++) {
moveWest();
}
} else {
}
Startpunktx = p[j].x;
//System.out.println("Startpunktx= " + Startpunktx);
}
if ((p[j].y - Startpunkty) > 0) {
for (int i = 0; i <= (p[j].y - Startpunkty) - 1; i++) {
moveSouth();
}
} else if ((p[j].y - Startpunkty) < 0) {
for (int i = 0; i <= (p[j].y - Startpunktx) - 1; i++) {
moveNorth();
}
} else {}
Startpunkty = p[j].y;
// System.out.println("Startpunkty= " + Startpunkty);
} markCurrentNode(Color.RED);
}
}