Bug 698 - Redo command cannot performed after an undo command
Summary: Redo command cannot performed after an undo command
Status: RESOLVED FIXED
Alias: None
Product: River-Crossing-Puzzle-Solver
Classification: Unclassified
Component: UI (show other bugs)
Version: v0.1.0
Hardware: PC Mac OS
: High normal
Assignee: tsunychau2-c
URL:
Depends on:
Blocks:
 
Reported: 2022-11-05 22:33 HKT by tsunychau2-c
Modified: 2022-11-05 22:35 HKT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tsunychau2-c 2022-11-05 22:33:10 HKT
Way to Reproduce:

1. Run Main.java inside folder Default

2. Input "2" on the console for choosing Player Mode

3. Input "1" for choosing game level

4. Input "farmer" on the console

5. Input "sheep" on the console

6. Input "s" on the console to start the boat

7. Input "u" on the console to undo previous step

8. Input "r" on the console to undo previous step

Actual Result:

Please use the following command to take action: 
FULL NAME 			 Choose a role on the boat side and Enter the full role name put the role to the boat
's' 				 To start the boat
'e' 				 To exit the program
'u' 				 To undo the action if exist
'r' 				 To redo the action if exist
You command: r
Sorry nothing can be redo!



= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
~ ~ ~ ~ ~ ~ ~ . . . . . . . . . B o a t . . . . . . . . . ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
~ ~ ~ ~ ~ ~ ~ [                                         ]~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
farmer tiger sheep grass 

---------------------------------------------------------------------------------------------------------
Please use the following command to take action: 
FULL NAME 			 Choose a role on the boat side and Enter the full role name put the role to the boat
's' 				 To start the boat
'e' 				 To exit the program
'u' 				 To undo the action if exist
'r' 				 To redo the action if exist
You command: 


Expect Result:

Please use the following command to take action: 
FULL NAME 			 Choose a role on the boat side and Enter the full role name put the role to the boat
's' 				 To start the boat
'e' 				 To exit the program
'u' 				 To undo the action if exist
'r' 				 To redo the action if exist
You command: r

farmer sheep 
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =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~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
tiger grass 

---------------------------------------------------------------------------------------------------------
Please use the following command to take action: 
FULL NAME 			 Choose a role on the boat side and Enter the full role name put the role to the boat
's' 				 To start the boat
'e' 				 To exit the program
'u' 				 To undo the action if exist
'r' 				 To redo the action if exist
You command:
Comment 1 tsunychau2-c 2022-11-05 22:33:30 HKT
Bug is confirmed
Comment 2 tsunychau2-c 2022-11-05 22:35:39 HKT
In RedoHandlerCommand.java, on line 23, gameState.undoRedoPointer should be <  gameState.history.size().

Modification of code:

public boolean canRedo() {
		if(gameState.undoRedoPointer < gameState.history.size() && gameState.round.getTravelers().size() == 0 && gameState.history.size() > 1)
			return true;
		else
			return false;
		
	}