File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Painting shells Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Painting shells" Watch "Painting shells" New topic
Author

Painting shells

eric elysia
Ranch Hand

Joined: Mar 06, 2005
Posts: 70
I am writing a program to paint shells, for example:

149
238
567

I have written a method, but the method is not giving me the results I expect.

The approach I am using is:

rowNum = 1
As long as row is less than the size of the square side (for each row in column 1)

As long as rowNum is greater than colNum
Paint horizontally, moving from left to right
When rowNum = colNum, paint that square, then exit loop

As long as rowNum is greater than 1
Paint vertically moving up
When rowNum = 1, paint that square, then exit loop



I am getting an infinite loop, but I am not sure what condition(s) are causing the infinite loop.

[ February 10, 2007: Message edited by: eric elysia ]
[ February 10, 2007: Message edited by: eric elysia ]
eric elysia
Ranch Hand

Joined: Mar 06, 2005
Posts: 70
OK, I got my loop figured out. Now I need to be able to change the color for each shell. I know where I need to change the color, but I am not sure how to compare the color.

I do know how to set the color: graphics.setColor(Color.red);

I thought about using an if statement like this:


Here is my working paintShells method:

[ February 11, 2007: Message edited by: eric elysia ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Painting shells
 
Similar Threads
Array of Arrays?
Tile constraints
Two Dimensional Arrays
Maximum Sum Project!!
Applet notinited