The very last for loop listed (int variables n and o).. I'm very new to any type of programming and in our introductory course we use Dr Java and some Basic media stuff to make what is essentially a turtle pen. It draws things on a display.
My last for loop seems to (in my eyes) say that it should initiate when n<=o which they are at the first. So it initiates. It should then update so that n=2 which is NOT <=o (1).. but yet it just keeps infinitely looping the very last part...
import Media.*;
import static java.lang.Math.*;
public class DiamondTiles2 {
private TurtleDisplayer display;
private Turtle steve;
public DiamondTiles2 (){
display = new TurtleDisplayer();
steve = new Turtle();
display.placeTurtle(steve);
steve.setSpeed(15);
steve.forward(140); // Moves Steve to the furthest right he needs to be
steve.left(PI/2);
steve.forward((float)1.5*(40*sqrt(3.0))); // Moves Steve to the top (up 1.5 times the height of a diamond)
steve.left(PI/6);
steve.penDown();
for (int m=1 ; m<=4 ; m++){
for (int j=1 ; j<=7 ; j++){ //Diamond Drawing
steve.forward(40);
steve.left(2*PI/3);
steve.forward(40);
steve.left(PI/3);
steve.forward(40);
steve.left(2*PI/3);
steve.forward(40);
steve.left(PI/3);
for (int i=1 ; i<=1 ; i++){
steve.penUp();
steve.left(PI/3);
steve.forward(40);
steve.right(PI/3);
steve.penDown();
for (int k=1 ; j>=7 ; k++){
for (int n=1, o=1 ; n<=o ; n=n+2){
steve.right(7*PI/6);
steve.forward((float)40*(sqrt(3.0)));
steve.left(PI/2);
steve.forward(280);
steve.left(2*PI/3);*
}
}
}
}
}
display.close();
};
Basically the end result should be that the last loop (n,o) only initiates once every 7 loops of j. What it does is draw 7 diamonds and then the n,o loop moves it down to start a new row where it would then draw another 7 diamonds! But it just keeps moving over and down indefinitely..