Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

I have to code Conway's game of life in java...?

alright so i am completely on how to code Conway's game of life. It is due tomorrow at midnight and so far all i have to offer is the rules with most of it just in logic form... I have absolutely no idea how to add graphics to it. It does not have to anything really special just text based with some user input for size and generations simulated. And how do you make it slow down the while loop so it does not just find the end result but show the changes in the JFrame.

import java.util.*;

import java.awt.*;

import java.awt.geom.*;

import javax.swing.*;

public class Conways_Life extends JComponent

{

//user input on life cycles and grid size

Scanner rote = new Scanner(System.in);

System.out.println("How many life cycles would you like to simulate?");

int z = rote.nextInt();

Scanner grid = new Scanner(System.in);

System.out.println("How big would you like the Y axis to be on your grid?");

int h = grid.nextInt();

Scanner grid2 = new Scanner(System.in);

System.out.println("How big would you like the X axis to be on your grid");

int w = grid2.nextInt();

/*public colorSet(String q)

{

Scanner color = new Scanner(System.in);

System.out.println("What color would you like your cells to be?");*/

//setting up counter variable for cut off point

int c = 0;

public int x = 0;

public int y = 0;

public int a = 10;

public int e = 0;

public int d = 0;

/*Any live cell with fewer than two live neighbours dies, as if caused by under-population.

Any live cell with two or three live neighbours lives on to the next generation.

Any live cell with more than three live neighbours dies, as if by overcrowding.

Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.*/

while (c <= z)

{

while ( y <= h )

{

while ( x <= w )

{

Rectangle Cell = new Rectangle(x, y, a, a);

g2.setColor(Color.);

g2.fill

x+a;

}

y+a;

}

if ( <1 || >3 )

{set.visable(false);}

if ( dead cell neighbors = 3)

{set.visable(true);}

if (== 2 || == 3)

{set.visable(true);}

c+1;

}

}

as you cans see from the crudity this is my code i have worked on it for the last week and i am stuck at this point. This is truly my last resort please if somebody on here could assist me it would be greatly appreciated.

here is what it is supposed to look like minus the buttons those are really not needed especially cause we have not been taught how to do them yet.

http://www.bitstorm.org/gameoflife/

Update:

it actually is weeks worth of work, my group members were lazy ***** and never showed up so i had to do everything on my own

3 Answers

Relevance
  • Anonymous
    9 years ago
    Favorite Answer

    That CANNOT be a weeks worth of work!

    http://www.bitstorm.org/gameoflife/code/

    You can copy/paste at will since you're asking someone else to do the work for you and you left it till the last minute... Good luck!

  • ?
    Lv 4
    5 years ago

    Game Of Life Java

  • 6 years ago

    This Site Might Help You.

    RE:

    I have to code Conway&#39;s game of life in java...?

    alright so i am completely on how to code Conway&#39;s game of life. It is due tomorrow at midnight and so far all i have to offer is the rules with most of it just in logic form... I have absolutely no idea how to add graphics to it. It does not have to anything really special just text based...

    Source(s): code conway 39 game life java: https://shortly.im/Fkgcy
Still have questions? Get your answers by asking now.