Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Painting shells

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic