Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** @param command */
- public void executeCommand(Command command) {
- // TODO: implement
- for(int i = commands.size() -1; i > currentCommandIndex; i--){
- commands.remove(i); // praznjenje redo liste
- }
- commands.add(command);
- command.execute();
- currentCommandIndex++;
- }
- public void undo() {
- // TODO: implement
- if(currentCommandIndex > -1){
- Command currentCommandToUndo = commands.get(currentCommandIndex);
- currentCommandToUndo.undo();
- currentCommandIndex--;
- }
- }
- public void redo() {
- // TODO: implement
- if(currentCommandIndex < commands.size() -1){
- Command currentCommandToRedo = commands.get(currentCommandIndex + 1);
- currentCommandToRedo.execute();
- currentCommandIndex++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement