Question

I'm trying to modify a current method for drawing a square:

length = 100;

            int index = 1;

            while (index <= 4) {
                    tParam.forward(length);
                    tParam.turn(90);
                    index++;
            }

Basically can't figure out what to change tParam.turn(); to. Help?

Était-ce utile?

La solution

This should work:

int height = 100; //the height of the rectangle
int width = 200; //the width of the rectangle
for(int i = 0; i < 2; i++) //repeat the following twice
{
    tParam.forward(height); //go forward the height of the rectangle
    tParam.turn(90); //turn 90 degrees
    tParam.forward(width); //go forward the width of the rectangle
    tParam.turn(90); //turn 90 degrees
} //end loop
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top