forked from hazukac/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMain.java
More file actions
34 lines (32 loc) · 1.13 KB
/
Copy pathMain.java
File metadata and controls
34 lines (32 loc) · 1.13 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
public class Main {
public static void main(String[] args) {
if (args.length != 2) {
System.out.println("Usage: java Main seed1 seed2");
System.exit(0);
}
int seed1 = Integer.parseInt(args[0]);
int seed2 = Integer.parseInt(args[1]);
Player p1 = new Player("Tainaka", new WinningStrategy(seed1));
Player p2 = new Player("Akiyama", new ProbStrategy(seed2));
int totalGameCount = 100;
for (int i = 0; i < totalGameCount; i++) {
Hand hand1 = p1.nextHand();
Hand hand2 = p2.nextHand();
System.out.println(hand1.toString());
System.out.println(hand2.toString());
if (hand1.isStrongerThan(hand2)) {
p1.win();
p2.lose();
} else if (hand2.isStrongerThan(hand1)) {
p1.lose();
p2.win();
} else {
p1.even();
p2.even();
}
}
System.out.println("Game set");
System.out.println(p1.toResultString());
System.out.println(p2.toResultString());
}
}