Skip to content

Commit

Permalink
littlechange
Browse files Browse the repository at this point in the history
  • Loading branch information
04vmatsibekker committed Jul 28, 2023
1 parent 4c89013 commit c66cc26
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
15 changes: 15 additions & 0 deletions src/main/java/edu/rpi/legup/history/PuzzleCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ public final void execute() {
}
}

/**
* Executes an command
*/
@Override
public final void execute(TreeTransition thisTreeTransition) {
if (canExecute()) {
executeCommand(thisTreeTransition);
state = CommandState.EXECUTED;
}
}

/**
* Determines whether this command can be executed
*/
Expand Down Expand Up @@ -66,6 +77,10 @@ public final String getError() {
* Executes an command
*/
public abstract void executeCommand();
/**
* Executes an command
*/
public abstract void executeCommand(TreeTransition thisTreeTransition);

/**
* Undoes an command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public String checkRuleAt(TreeTransition transition, PuzzleElement puzzleElement
*/
@Override
public String checkRuleRaw(TreeTransition transition) {
return checkContradiction(transition.getBoard());
return checkContradiction(transition);
}

/**
Expand All @@ -89,9 +89,9 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem
* @param board board to check contradiction
* @return null if the tree node contains a contradiction, otherwise error message
*/
public String checkContradiction(Board board) {
for (PuzzleElement puzzleElement : board.getPuzzleElements()) {
String checkStr = checkContradictionAt(board, puzzleElement);
public String checkContradiction(TreeTransition transition) {
for (PuzzleElement puzzleElement : transition.getNewPuzzleElements()) {
String checkStr = checkContradictionAt(transition.getBoard(), puzzleElement);
if (checkStr == null) {
return checkStr;
}
Expand Down

0 comments on commit c66cc26

Please sign in to comment.