Java -URGENT please help Note that the examples are only for demonstratration Co
ID: 3902256 • Letter: J
Question
Java -URGENT please help
Note that the examples are only for demonstratration
Continued with https://www.chegg.com/homework-help/questions-and-answers/question-2-game-life-50-points-question-write-java-program-implements-simple-version-conwa-q29764348
2d) Method to create the next generation universe Write a method getNextGenUniverse that takes as iput a two-dimensional array of integers represent- ing a valid universe and returns a two-dimensional array of integers (with equal dimensions) representing the universe in its next generation. To get full marks, your method must call getNextGenCell) For example, consider the following arrays: int [] C) tub-tO,0,0,0,0, to,0,1,0,0), 10,1,0,1,0, t0,0,1,0,0, t0,0,0,0,0); int[ C toad t0,0,0,0,0,0, 0,0,1,1,1,0, (0,1,1,1,0,0, t0,0,0,0,0,0); int C pentadec-o,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0, 10,0,0,0,1,0,0,0,0, t0,0,0,0,1,0,0,0,o), t0,0,0,1,0,1,0,0,0, t0,0,0,0,1,0,0,0,0, (0,0,0,0,1,0,0,0,0, 0,0,0,0,1,0,0,0,0, 10,0,0,0,1,0,0,0,0, 10,0,0,1,0,1,0,0,0) (0,0,0,0,1,0,0,0,0, t0,0,0,0,1,0,0,0,0, t0,0,0,0,0,0,0,0,0, to,0,0,0,0,0,0,0,0), (0,0,0,0,0,0,0,0,0; Then: getNextGenUniverse (tub) returns the following array: C0,0,0,0,03, 10,0,1,0,0, 0,1,0,1,o, t0,0,1,0,0, to,0,0,0,0H getNextGenUniverse(toad) returns the following array: t0,0,0,1,0,03, 10,,0,0,1,o, t0,1,0,0,1,0), to,0,1,0,0,0) getNextGenUniverse (pentadec) returns the following array: (t0,0,0,,0,0,0,0,0, t0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0, tO,0,0,0,0,0,0,0,0, t0,0,0,1,,0,0,0, t0,0,0,1,0,1,0,0,0, 0,0,0,1,,,0,0,0, t0,0,0,,,,0,0,0, t0,0,0,0,0,0,0,0,03, 10,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0, t0,0,0,0,0,0,0,0,0Explanation / Answer
here i am giving you the code please replace in your code : ------------->>>>>>>>>>
public class NextGenSimulation{
public static int[][] getNextGenUniverse(int[][] world){
int[][] newWorld = new int[world.length][world[0].length];
for(int i = 0;i<world.length;i++){
for(int j = 0;j<world[0].length;j++){
newWorld[i][j] = getNextGenCell(world,i,j);
}
}
}
public static void simulateGeneration(int[][] world,int n)throws IllegalArgumentException{
if(isValidUniverse(world)){
System.out.println("Original Seed");
displayUniverse(world);
for(int i = 1;i<=n;i++){
world = getNextGenUniverse(world);
System.out.println("Generation "+i);
displayUniverse(world);
}
}else{
throw new IllegalArgumentException("Universe has not a valid generations ");
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.