-
Notifications
You must be signed in to change notification settings - Fork 2
/
ThresholdStrategy.java
37 lines (32 loc) · 1.01 KB
/
ThresholdStrategy.java
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
26
27
28
29
30
31
32
33
34
35
36
37
package ehs.mat.strategy;
import ehs.mat.game.BlackjackDeck;
import ehs.mat.game.BlackjackGame;
/**
* A basic implementation of strategy that never splits and always hits if the total is below a threshold
* @author Joseph Azevedo
*/
public class ThresholdStrategy extends Strategy {
private int threshold;
public ThresholdStrategy(int threshold) {
super();
this.threshold = threshold;
}
@Override
protected boolean shouldSplit(BlackjackGame g, BlackjackDeck deck) {
return false;
}
@Override
protected boolean performSoftDeckAction(BlackjackGame g, BlackjackDeck deck) {
if(deck.getMaxTotal() < threshold) {
g.hit(deck);
return true;
} else return false;
}
@Override
protected boolean performHardDeckAction(BlackjackGame g, BlackjackDeck deck) {
if(deck.getMaxTotal() < threshold) {
g.hit(deck);
return true;
} else return false;
}
}