Summary: It's found that when one player checkmate and already wins the game, the opponent can still act by input "undo" and move command. Steps to Reproduce: 1. Run the program 2. Input "new game" 3. Input "4 3 4 4" 4. Input "1 7 4 7" 5. Input "4 4 4 5" 6. Input "4 6 4 5" 7. Input "0 0 0 1" 8. Input "4 7 4 0" 9. Input "undo" Actual Result: The move "0 0 0 1" is undone. Expected Result: No further command is acceptable when one player already wins. And error message needs to be prompted.
(In reply to Marco from comment #0) > Summary: > It's found that when one player checkmate and already wins the game, the > opponent can still act by input "undo" and move command. > > Steps to Reproduce: > 1. Run the program > 2. Input "new game" > 3. Input "4 3 4 4" > 4. Input "1 7 4 7" > 5. Input "4 4 4 5" > 6. Input "4 6 4 5" > 7. Input "0 0 0 1" > 8. Input "4 7 4 0" > 9. Input "undo" > > Actual Result: > The move "0 0 0 1" is undone. > > Expected Result: > No further command is acceptable when one player already wins. And error > message needs to be prompted. Solution provided by Marco: The bug is solved by adding a new boolean variable called "gameOver" in ChessBoard.java and it will be changed into "true" whenever game ends: case ErrorCode.GAME_ALREADY_OVER: gameOver = true; System.out.println("The game is over!"); break; In this case, when we issue "undo" after game ends, the program will first check the value of "gameOver": public int undo() { if (gameOver) { System.out.println("The game is over! Undo is not allowed."); return ErrorCode.GAME_ALREADY_OVER; } ... ... } Then this bug is successfully fixed.