-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWinCheckStrategy.java
More file actions
25 lines (23 loc) · 935 Bytes
/
Copy pathWinCheckStrategy.java
File metadata and controls
25 lines (23 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/**
* WinCheckStrategy is the abstract class which defines "check" and setWinCheckStrategy api
* to capture the essense of "Chain of Responsibility" pattern.
*/
public abstract class WinCheckStrategy {
protected WinCheckStrategy winCheckStrategy;
/**
* setWinCheckStrategy method sets the next strategy call to form a chain to check
* various win scenarios i.e. horizontal, vertical, and diagonal.
*
* @param winCheckStrategy this point to the next strategy calls in chain of responsibility
*/
public void setWinCheckStrategy(WinCheckStrategy winCheckStrategy) {
this.winCheckStrategy = winCheckStrategy;
}
/**
* check is an abstract method to check for win condition across horizontal, vertical,
* forward diagonal and backword diagonal.
*
* @param board the model to be validated for win condition.
*/
abstract boolean check(Board board);
}