-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathStrategyPatternTest.java
More file actions
35 lines (34 loc) · 1.32 KB
/
StrategyPatternTest.java
File metadata and controls
35 lines (34 loc) · 1.32 KB
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
package Strategy_Pattern;
public class StrategyPatternTest {
public static void main(String[] args) {
if(args.length != 2) {
System.out.println("Usage: java StrategyPatternTest randomseed1 randomseed2");
System.out.println("Example: java StrategyPatternTest 314 15");
System.exit(0);
}
int seed1 = Integer.parseInt(args[0]);
int seed2 = Integer.parseInt(args[1]);
Player player1 = new Player("KIM", new WinningStrategy());
Player player2 = new Player("LEE", new ProbStrategy());
for(int i = 1; i <= 10000; i++) {
Hand nextHand1 = player1.nextHand();
Hand nextHand2 = player2.nextHand();
if(nextHand1.isStrongerThan(nextHand2)) {
System.out.println("Winner: " + player1);
player1.win();
player2.lose();
} else if (nextHand2.isStrongerThan(nextHand1)) {
System.out.println("Winner: " + player2);
player1.lose();
player2.win();
} else {
System.out.println("Even...");
player1.even();
player2.even();
}
}
System.out.println("Total result: ");
System.out.println(player1);
System.out.println(player2);
}
}