자바에서 이게 왜 에러가 나는거죠?
조회수 11236회
테트리스 게임을 만들고있는데요. 아래 코드를 실행하면 Shape is not an enclosing class라는 메세지가 나와요.
public class Test {
public static void main(String[] args) {
Shape s = new Shape.ZShape();
}
}
public class Shape {
private String shape;
private int[][] coords;
private int[][] noShapeCoords = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } };
private int[][] zShapeCoords = { { 0, -1 }, { 0, 0 }, { -1, 0 }, { -1, 1 } };
private int[][] sShapeCoords = { { 0, -1 }, { 0, 0 }, { 1, 0 }, { 1, 1 } };
private int[][] lineShapeCoords = { { 0, -1 }, { 0, 0 }, { 0, 1 }, { 0, 2 } };
private int[][] tShapeCoords = { { -1, 0 }, { 0, 0 }, { 1, 0 }, { 0, 1 } };
private int[][] squareShapeCoords = { { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 } };
private int[][] lShapeCoords = { { -1, -1 }, { 0, -1 }, { 0, 0 }, { 0, 1 } };
private int[][] mirroredLShapeCoords = { { 1, -1 }, { 0, -1 }, { 0, 0 }, { 0, 1 } };
public Shape(){
int[][] coords = noShapeCoords;
shape = "NoShape";
}
class ZShape{
int[][] coords = zShapeCoords;
String shape = "ZShape";
}
class SShape{
int[][] coords = sShapeCoords;
String shape = "SShape";
}
//etc
}
뭐가 잘못된거죠?
댓글 입력