Java loop structure
Hello, i need help on a loop stucture for a java programming i am doing.
Imagine that you have a 20x20 grid and i need to get "fishes" to appear clockwise starting at the top left corner, then going in circles, in a swirl pattern, clockwise.
01 02 03 04 05 06 07 08 09 10
38 39 40 41 42 43 44 45 46 11
37 ****************47 12
36*****************48 13
35*****************49 14
34*****************50 15
33*****************51 16
32********************17
31 *******************18
30********************19
29 28 27 26 25 24 23 22 21 20
and so on
if i could get a basic loop stucture, taht would be good
thanks
Imagine that you have a 20x20 grid and i need to get "fishes" to appear clockwise starting at the top left corner, then going in circles, in a swirl pattern, clockwise.
01 02 03 04 05 06 07 08 09 10
38 39 40 41 42 43 44 45 46 11
37 ****************47 12
36*****************48 13
35*****************49 14
34*****************50 15
33*****************51 16
32********************17
31 *******************18
30********************19
29 28 27 26 25 24 23 22 21 20
and so on
if i could get a basic loop stucture, taht would be good
thanks
0
Comments
Also, how is it indexed?
0,0...n,0
.
.
.
0,m...n,m
i assume?
thanks anyways!
{ int a = 0; int b = 0; int c = 1; int color = 1; int z = 0; FishGfx f = new FishGfx(g,20,20,1000); while (z< 10) { for (a=0+z,b=0+z;b< 20-z;b++,c++) f.drawFish(g,a,b,color,String.valueOf(c)); color++; if (color ==10) color = 1; for (a=0+z+1,b=19-z;a<20-z;a++,c++) f.drawFish(g,a,b,color,String.valueOf(c)); color++; if (color ==10) color = 1; for (a=19-z,b=19-z-1;b>= 0+z;b--,c++) f.drawFish(g,a,b,color,String.valueOf(c)); color++; if (color ==10) color = 1; for (a=19-z-1,b=0+z;a> 0+z;a--,c++) f.drawFish(g,a,b,color,String.valueOf(c)); color++; if (color ==10) color = 1; z++; } z=0;attached are all the files if you want to execute it and see the output