Question: Hello I need help with My code. I still need to figure out GetNeighbhors, and Scanner user input. I need it ASAP. and can you
Hello I need help with My code. I still need to figure out GetNeighbhors, and Scanner user input. I need it ASAP. and can you please comment on what you did aswell that will be easier to understand.
import java.util.Scanner;
import java.util.Random; public class Life {
private char[][] world; private char[][] glider = { {' ','*',' '}, {' ','*','*'}, {'*',' ','*'}}; private char[][] patternB = { {'*','*',' '}, {'*',' ','*'}, {' ','*','*'}}; private char[][] patternC = { {' ',' ',' '}, {' ','*','*'}, {' ','*','*'}}; public void putGlider(int r_pos,int c_pos){ for(int x = 0; x=0 && c>= 0 && r 3){ newWorld[row][col] = ' ' ; } if(world[row][col] == '*' && (getNeighbors(row,col) == 3 || getNeighbors(row,col) == 2)){ newWorld[row][col] = '*'; } if(world[row][col] == " " && getNeighbors(row,col) == 3){ newWorld[row][col] = "*"; } //newWorld[row][col] = isAlive(row, col); } } world = newWorld; generation++; } // Calculate if an individual cell should be alive in the next generation. // Based on the game logic: void isAlive(int row, int col){ int liveCount = 0; char cellCurrentlyAlive = world[row][col]; for(int r = -1; r <= 1; r++){ int currentRow = row + r; currentRow = (currentRow < 0)? dimension - 1: currentRow; currentRow = (currentRow >= dimension)? 0 : currentRow; for(int c = -1; c <= 1; c++){ int currentCol = col + c; currentCol = (currentCol < 0)? dimension - 1: currentCol; currentCol = (currentCol >= dimension)? 0 : currentCol; //if(world[currentRow][currentCol]){ //liveCount++; } } }blic static void main(String[] args) throws java.lang.InterruptedException{ Life earth = new Life(10); earth.putGlider(4,4); earth.printBoard(); //earth.drawWorld(); while(true){ Thread.sleep(1000); earth.nextGeneration(); earth.printBoard(); } } }