![]() |
|
#1
|
|||
|
|||
Newbie "if" Nested in "while" QuestionI'm working on the same problem a couple other students have posted here.
It's a Karel program, drawing a checkerboard pattern. The trick is that it must work regardless of the dimensions of the world. My program works perfectly when there are an odd number of rows, but doesn't when there are an even number. After Karel completes the first odd row, I have a while loop that only continues to draw an even row if his rightIsClear. Within that while loop, following his drawing an even row, he will draw the next odd row, but only if his rightIsClear once again. Draws like a dream and stops just fine when his world contains an odd number of rows. So the while loop is working fine.. But with even numbers of rows, he attempts to move on to an additional row even though "if (rightIsClear)" should return false. Well, if anyone could tell me why this doesn't work, it would really help me learn how to use these conditional statements correctly. Many thanks to my virtual professors! Here is the code: JAVA Code:
|
|||
|
#2
|
||||
|
||||
Re: Newbie "if" Nested in "while" QuestionI think the problem is a 'stray' semicolon:
JAVA Code:
__________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#3
|
|||
|
|||
Re: Newbie "if" Nested in "while" QuestionGood eye! Works like a charm now!
Thank you so much. |
Recent GIDBlog
Programming ebook direct download available by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Newbie question on saving files | goose21 | C Programming Language | 3 | 09-Sep-2007 22:45 |
| Help with nested for loops...please. sorry newbie | keperry | C++ Forum | 14 | 16-Oct-2004 12:25 |
| Grouping data from MySQL with PHP - Newbie question. | giobbi | MySQL / PHP Forum | 12 | 27-Feb-2004 01:34 |
| Newbie Question about Borland | andrewcarraway | C++ Forum | 4 | 24-Jan-2004 12:17 |
| Code problem (a newbie question) | monkster87 | C++ Forum | 3 | 11-Aug-2003 13:46 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The