hey Leute
irgendwie geht dieses Programm bei mir ned.. aber ich weis ned warum... kann mir vll wer helfen?
ich freu mich schon auf eure Antwort und bedank mich schon amal im Vorraus für eure Hilfe
greetz
irgendwie geht dieses Programm bei mir ned.. aber ich weis ned warum... kann mir vll wer helfen?
Java:
import java.util.*;
public class GameofLife{
public static void output(boolean [][] m){
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
if(m[i][j]){
System.out.print("X");
} else {
System.out.print(" ");
}
}
}
public static int countworld(boolean [][] m, int x, int y){
int ret = 0;
for(int i=(x-1);i<(x+2);i++){
for(int j=(y-1);j<(y+2);j++){
try{
if(m[i][j]){
ret+=1;
}
}
catch (IndexOutOfBoundsException e) { }
}
}
if (m[x][y])
ret-=1;
}
//END
}
public static void main (String [] args){
boolean[][] world = new boolean[10][10];
boolean[][] worldnew = new boolean[10][10];
Random generat = new Random();
double randvalue;
for(int i=1;i<10;i++){
for(int j=1;j<10;j++){
randvalue = generat.nextDouble();
if(randvalue>=0.5){
world[i][j] = true;
}
}
}
int i=0;
System.out.print("Generation" + i++);
System.out.println();
GameofLife.output(world);
//END main
}
//END GameOfLife
}
ich freu mich schon auf eure Antwort und bedank mich schon amal im Vorraus für eure Hilfe
greetz