Results 1 to 1 of 1
- 03-05-2010, 03:57 AM #1
Member
- Join Date
- Mar 2010
- Posts
- 1
- Rep Power
- 0
Nested Loop help -- concerning image repetition
Hey everyone,
I'm relatively new to the forums, and very new to java. I'm currently supposed to be writing a program that alternates faces on the paint canvas. I've got everything down, as far as the alternating faces go and having the printed faces set up... however, I can't get it to repeat the faces a certain number of times, break, and then go to the next line. I need something like 4 faces per line, alternating. and I need to use nested for loops to do it...its got me stumped.
Here's the little chunk of code I'm working on that that has neither correct syntax and probably not correct logic but i'm still working on it so...
Basically I'm trying to put a for loop inside a for loop, but I haven't worked with this much. I'm trying to say something like "once xOffset reaches a certain point use yOffset once to move it down then repeat the loop...then do the yOffset part again.Java Code:int value = 0, xOffset = 0, yOffset = 0; for (yOffset = 0, xOffset = 0, value = 0; xOffset <= 2000; xOffset++) { if (xOffset <= 2000) xOffset = 200 * value; else yOffset = 200 * value; { for (value = 0; value <= 4; value++) { if (isOdd(value)) { sadFace(xOffset, yOffset, canvas); } else { happyFace(xOffset, yOffset, canvas); } } }
Not even sure if this makes sense to anyone, but I thought i'd give it a shot. Any sort of help would be appreciated...pokes in the right directions..alternative ways of thinking, etc.
Thanks for any help.
Similar Threads
-
Explanation of Nested Loop (very strange)
By Jonotron in forum New To JavaReplies: 5Last Post: 01-09-2011, 02:54 AM -
can some one help me with nested loop?
By keycoffee in forum New To JavaReplies: 10Last Post: 01-25-2010, 02:49 AM -
while Loop (Repetition) structure.
By gapeach97 in forum New To JavaReplies: 9Last Post: 12-03-2008, 11:52 PM -
nested for loop question
By javabob in forum New To JavaReplies: 3Last Post: 05-20-2008, 11:00 PM -
Nested For Loop
By yuchuang in forum New To JavaReplies: 1Last Post: 07-08-2007, 01:11 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks