“void是变量paintSquare的无效类型”错误

时间:2023-02-07 22:34:41

I'm making a Tetris clone for my AP Comp Sci class properly titled 'Titris' and while going through whatever errors there were I got this one. it came from this code

我正在为我的AP Comp Sci课程制作一个俄罗斯方块克隆,正确地标题为'Titris',并且在经历任何错误时我得到了这个。它来自这个代码

private void paintSquare(Graphics g1, int x, int y) { Color color = matrix[y][x]; int xMin = x * squareSize.width; int yMin = y * squareSize.height; int xMax = xMin + squareSize.width - 1; int yMax = yMin + squareSize.height - 1; int i; bufferRect.x = xMin; bufferRect.y = yMin; bufferRect.width = squareSize.width; bufferRect.height = squareSize.height; if (!bufferRect.intersects(g1.getClipBounds())) { return; }

private void paintSquare(Graphics g1,int x,int y){Color color = matrix [y] [x]; int xMin = x * squareSize.width; int yMin = y * squareSize.height; int xMax = xMin + squareSize.width - 1; int yMax = yMin + squareSize.height - 1; int i; bufferRect.x = xMin; bufferRect.y = yMin; bufferRect.width = squareSize.width; bufferRect.height = squareSize.height; if(!bufferRect.intersects(g1.getClipBounds())){return; }

The error coming from paintSquare

来自paintSquare的错误

Please help, this project is due soon & I don't know what to do about this error.

请帮助,这个项目即将到期,我不知道如何处理这个错误。

2 个解决方案

#1


2  

Remove the semicolon after your argument list.

在参数列表后删除分号。

private void paintSquare(Graphics g1, int x, int y) {

#2


2  

private void paintSquare(Graphics g1, int x, int y); {

should be

private void paintSquare(Graphics g1, int x, int y) {

The semicolon after the parameters is breaking your code.

参数后面的分号会破坏您的代码。

#1


2  

Remove the semicolon after your argument list.

在参数列表后删除分号。

private void paintSquare(Graphics g1, int x, int y) {

#2


2  

private void paintSquare(Graphics g1, int x, int y); {

should be

private void paintSquare(Graphics g1, int x, int y) {

The semicolon after the parameters is breaking your code.

参数后面的分号会破坏您的代码。