-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix logic in OneMoveForwardHandler class and TwoMovesForwardHandler c…
…lass to move within a fixed column
- Loading branch information
Showing
7 changed files
with
46 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package handlers;public class EnemyOnDestinationHandler { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package handlers;public class LeftSquareDiagonallyHandler { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package handlers;public class RightSquareDiagonallyHandler { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/movements/LeftSquareDiagonallyIfEnemyExistsStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package movements; | ||
|
||
import board.Board; | ||
import general.Square; | ||
import handlers.*; | ||
|
||
public class LeftSquareDiagonallyIfEnemyExists extends BaseHandler { | ||
@Override | ||
protected boolean isValid(Board board, Square from, Square to) { | ||
if (board == null || from == null || to == null) { | ||
throw new IllegalArgumentException("NullPointer argument"); | ||
} | ||
|
||
BaseHandler handler1 = new ValidStartLocationHandler(); | ||
BaseHandler handler2 = new ValidDestinationHandler(); | ||
BaseHandler handler3 = new LeftSquareDiagonallyHandler(); | ||
BaseHandler handler4 = new EnemyOnDestinationHandler(); | ||
handler1.setNext(handler2); | ||
handler2.setNext(handler3); | ||
handler3.setNext(handler4); | ||
|
||
return handler1.canHandle(board, from, to); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
src/movements/RightSquareDiagonallyIfEnemyExistsStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package movements;public class RightSquareDiagonallyIfEnemyExists { | ||
} |