0

我收到两条错误消息:一条说class GameState is already defined in package unnamed package
,另一条说:在这一行找不到符号 this.gameStatus = gameStatus.continues;

这是我的代码:

public class GameState 
{
    private enum GameState {win, lose, continues};
    private GameState gameStatus;


    public GameState() {    
        initializeGameState();
    }

    public void initializeGameState() {
        this.gameStatus = gameStatus.continues;
    }
}

提前致谢

4

1 回答 1

3

使用其名称引用特定枚举:

this.gameStatus = GameState.continues;

代替

this.gameStatus = gameStatus.continues;

此外,将您的枚举命名为与您的类名不同的名称。

于 2013-02-26T18:46:13.713 回答