-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogic.java
48 lines (48 loc) · 1.37 KB
/
Logic.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
public class Logic{
Tourney tournament;
public Logic(Ui inout){
tournament = new Tourney();
while(true){
int choice = inout.getOrRemoveOrDone();
if(choice == 1){
tournament.registerPlayer(inout.getPlayer());
} else if(choice == -1){
tournament.removePlayer(inout.removePlayer());
} else if(choice == 0){
break;
}
inout.showPlayers(tournament.getPlayers());
}
tournament.startTournament();
int numOfPlayers = tournament.numOfPlayers();
int rounds = 2;
int playerCap = 8;
while(numOfPlayers >= playerCap){
playerCap *= 2;
rounds++;
}
inout.displayRound(tournament.getRound());
while(true){
int choice = inout.reportOrDropOrFinish();
if(choice == 1){
if(!tournament.finishMatch(inout.getTable(), inout.getWin(), inout.getLoss(), inout.getDraw())){
System.out.println("Incorrect values entered.");
}
inout.displayRound(tournament.getRound());
} else if(choice == 0){
inout.showPlayers(tournament.getActive());
tournament.dropPlayer(inout.removePlayer());
} else if(choice == -1){
if(tournament.roundFinished()){
if(--rounds == 0) break;
tournament.nextRound();
inout.displayRound(tournament.getRound());
} else {
System.out.println("Haven't finished round yet.");
}
}
}
System.out.println("Finished Tournament");
inout.displayResult(tournament.getPlayers());
}
}