我收到两条错误消息:一条显示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;
}
}
提前致谢
最佳答案
使用名称引用特定的枚举:
this.gameStatus = GameState.continues;
代替
this.gameStatus = gameStatus.continues;
另外,为您的枚举命名不同于类的名称。