The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Help with my game of life program

I need help with my game of life program I have to write for an assignment. I need to create the game of life using an input called "testLab8.lif" and have the game of life run on a GUI. I have two classes, lifegrid (this has all the methods need to compute the game of life) and lifemain (this class has the main method inside it to run the program).
I'm a beginner to java and this is my first post on this website (or any forums site).

I'm having a problem with lifegrid class, I'm trying to call the run() method in the show() method so that the generations are printed using the show(). Here is lifegrid class: (I get an error saying "cannot find symbol:variable old/New/swap" it means for the line System.out.println("Generations: " + run(old, New, swap)); this line is in the show() method at the bottom.

Re: Help with my game of life program

Please highlight your code using tags as found in my signature.

System.out.println("Generations: " + run(old,New,swap));
Now then, It can't find those symbols...why would that be? possibly because you haven't defined them anywhere at all in the code (par of-course as local method parameters)?

Re: Help with my game of life program

What are those variables used for? Do any other methods need to see them?
Does their value need to be save past the end of the method where they are used?
If they are only used in one method, then define them inside of the method.
If other methods need to access them, then define them outside of the method as class variables.

Re: Help with my game of life program

The variables are use used to display the run() method but I not sure if is how to do it. (What I'm basically trying to with that command is to display my run() method using the show() method.
They need to be repeated to constantly show the different generations. They are used in one method and need to be called/accessed by another method in the same class.
__________________________________________________ __________________________________________________ _____________________________

I have changed the "lifegrid" class (below) as follows so that the run() method will be displayed using the show() method and ultimately the game of life should be displayed. Everything compiles fine but, nothing appears on the command line except blank lines. (Its like the program is running but nothing is displayed does anyone know why this happens.)

BTW this is what I am trying to do:5. Add a method run() which computes successive generations and prints
them using your show() method. You will need to maintain two grids:GUI interface 191
the original and the new. We suggest you have three grid variables old,
new and swap and two actual grids which are swapped at the end of each
generation.