我试图通过阅读文件来编写生命游戏,每个文件都有自己的闪光灯写成星号,然后我会阅读,如果有星号则只分配给数组元素。
例如:
int [] [] grid = new int [x][y];
Scanner file = new Scanner(new File("file.txt"));
int count;
int charCount;
int x;
int y;
for (count =0 ; file.hasNext();count++ )
{
file.nextLine();
x = count;
for(charCount = 0; file.hasNext(); charCount++);
file.findInLine("*").charAt(charCount);
y = charCount;
在伪代码中:
for each row in rows
read row from file
for each character in row
check if character is an asterisk
set value of integer array at row, col