Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

troubleshooting a button that doesn't work.

 
D diller
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finally finishing up that program that I got a bit of help on the other day, and it's coming together quite nicely except for one problem - when I click on my 'Next' button, nothing happens.

I have a 2D array of type Boolean which I randomly disperse 'True' values around in. It works great, and I can create an array of any size pretty much and have any number of elements be true or false. The 'Next' button will eventually be different than this, but it's like it's not executing at all.

That's for the 'Next' button, and my nextGeneration:


I realize that all my 'Next' button should do is just make all the values of my array false, and I have another button that does that and it works - in fact, I just copied and pasted that code. So can anybody give me any pointers/things to look for? I'm dumbfounded.

Side note: What does "String[] args" mean? like if I had 'public void nextGeneration(String[] args){' instead>
 
fred rosenberger
lowercase baba
Bartender
Posts: 12086
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"String[] args" means you are passing in an array of Strings, an will refer to it as 'args' within your method.

You would then refer to args[0], or args[1], or args[479] - with the usual index-out-of bounds caveats.
 
D diller
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright, got the code to run now; still not complete for how it should be, but it'll do.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm assuming that you're doing a Conway's Game of Life app. If so, then your next generation algorithm is the heart of your program, is the most important method that your app has. Basically it loops through your 2D array, and based on the current state of the array's cells determines whether each cell will be alive or dead in the coming generation. This formula is simple, is readily available at many sources including Wikipedia, and I'll bet in your notes. I'd give it a go if I were you, and we hope for the best. Come on back if you trip up.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic