Easy Java code help: for (int numEdges =2; numEdges <= 1; numEdges++)

Frosty3799

Diamond Member
Nov 4, 2000
3,795
0
0
for (int numEdges =2; numEdges <= 1; numEdges++)
{
myTurtle.move(200);
myTurtle.turnRight(90);
}


Ok, question is "what will the shape of the resulting for statement be?".

So, really I am asking what the numEdges command does, and also why and how many times will it cycle through the commands in the {}

Thanks a bunch.
 

gopunk

Lifer
Jul 7, 2001
29,239
2
0
numEdges is a variable

this code will do nothing

numEdges is set to 2, the condition for the for loop is that numEdges has to be less than or equal to 1. it never runs.

unless i'm making a really really dumb mistake (feels like it :D)
 

Frosty3799

Diamond Member
Nov 4, 2000
3,795
0
0
Originally posted by: gopunk
numEdges is a variable

this code will do nothing

numEdges is set to 2, the condition for the for loop is that numEdges has to be less than or equal to 1. it never runs.

unless i'm making a really really dumb mistake (feels like it :D)

It says its supposed to be "tricky" in the book, and I couldn't find anything in the chapter about the numEdges command... so I had jusut assumed that it had something to do with that and the trickiness. You are probably right though. Thanks for the assistance.
 

gopunk

Lifer
Jul 7, 2001
29,239
2
0
Originally posted by: Frosty3799
Originally posted by: gopunk
numEdges is a variable

this code will do nothing

numEdges is set to 2, the condition for the for loop is that numEdges has to be less than or equal to 1. it never runs.

unless i'm making a really really dumb mistake (feels like it :D)

It says its supposed to be "tricky" in the book, and I couldn't find anything in the chapter about the numEdges command... so I had jusut assumed that it had something to do with that and the trickiness. You are probably right though. Thanks for the assistance.

np :)

but remember, it's variable, not command :) and it could have been called anything, the name is really irrelevant.... it was just there for the loop's purposes.
 

BCYL

Diamond Member
Jun 7, 2000
7,803
0
71
gopunk is correct... It will never enter the loop and just skip it....