-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatch.java
66 lines (66 loc) · 1.4 KB
/
Match.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
public class Match{
Player player1, player2;
int win, loss, draw, round;
int table;
boolean done;
public Match(int roundNum, int tableNum, Player p1, Player p2){
player1 = p1;
player2 = p2;
player1.addOpp(player2);
player2.addOpp(player1);
round = roundNum;
table = tableNum;
win = 0;
loss = 0;
draw = 0;
}
public Match(int roundNum, Player player){
player1 = player;
player2 = null;
round = roundNum;
win = 2;
loss = 0;
draw = 0;
done = true;
}
public boolean matchResult(int w, int l, int d){
this.win = w;
this.loss = l;
this.draw = d;
if(win != 0 && win != 1 && win != 2) return false;
if(loss != 0 && loss != 1 && loss != 2) return false;
if(draw != 0 && draw != 1 && draw != 2) return false;
if((win + loss + draw) > 3) return false;
done = true;
return true;
}
public void finishMatch(){
player1.addMatch(win > loss ? 3 : (win == loss ? 1 : 0));
player1.addGames(win + loss + draw, win * 3 + draw);
if(player2 != null){
player2.addMatch(loss > win ? 3 : (win == loss ? 1 : 0));
player2.addGames(win + loss + draw, loss * 3 + draw);
}
}
public Player getPlayer1(){
return player1;
}
public Player getPlayer2(){
return player2;
}
public int getWin(){
return win;
}
public int getLoss(){
return loss;
}
public int getDraw(){
return draw;
}
public int getTable(){
return table;
}
public boolean getDone(){
return done;
}
}