• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

troubleshooting a button that doesn't work.

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alright, got the code to run now; still not complete for how it should be, but it'll do.
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Quick! Before anybody notices! Cover it up with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic