我已经仔细检查了一下我是否遗漏了语法,括号…等等。但还是不明白为什么7号线会有“意外代币”。仅供参考-这是定义类的第二个选项卡。
class Cell {
int alive;
int nearby;
int i;
int j;
Cell(i_,j_) {
alive = 0;
nearby = 0;
i = i_;
j = j_;
}
void show() {
if(alive==1) {
fill(0);
rect(i*scl,j*scl,scl,scl);
}
else {
noFill();
rect(i*scl,j*scl,scl,scl);
}
}
void check() {
nearby = 0;
nearby+=Cells[(i+1)%rows][(j+1)%rows].alive;
nearby+=Cells[(i+1)%rows][(j+rows-1)%rows].alive;
nearby+=Cells[(i+1)%rows][j].alive;
nearby+=Cells[(i+rows-1)%rows][(j+1)%rows].alive;
nearby+=Cells[(i+rows-1)%rows][(j+rows-1)%rows].alive;
nearby+=Cells[(i+rows-1)%rows][j].alive;
nearby+=Cells[i][(j+1)%rows].alive;
nearby+=Cells[i][(j+rows-1)%rows].alive;
}
void update() {
if (alive == 0 && nearby == 3) alive = 1;
else if (alive == 1 && (nearby > 3 || nearby < 2)) alive = 0;
}
}
1条答案
按热度按时间gpnt7bae1#
构造函数声明中缺少类型。这个,
应该是