所以我在构造函数时遇到了麻烦。我正在将我的 Tile 类中的构造函数调用到我的 Square 类中,并且构造函数应该没有参数。
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
public class Square extends Tile
{
static BufferedImage square = null;
public void Square()
{
try
{
square = ImageIO.read(new File("BlueSquare.png"));
}
catch (IOException e){}
}
public Square(int dVal, boolean walk, BufferedImage image)
{
super(1, true, square);
}
}
这是瓷砖类。
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
public class Tile
{
static int dataVal;
static boolean walkable;
static BufferedImage img;
public void Tile (int dVal, boolean walk, BufferedImage image)
{
dataVal = dVal;
walkable = walk;
img = image;
}
public static int getValue()
{
return dataVal;
}
public static boolean getWalk()
{
return walkable;
}
public static BufferedImage getImage()
{
return img;
}
}
我究竟做错了什么?