formatting
This commit is contained in:
parent
703097ad4d
commit
e7f7a20ea6
@ -8,7 +8,7 @@ public class ByeGame extends Game{
|
||||
private final String player1;
|
||||
private final Game ref;
|
||||
|
||||
ByeGame(String player1, Game ref){
|
||||
ByeGame(String player1, Game ref) {
|
||||
super();
|
||||
this.ref = ref;
|
||||
this.player1 = player1;
|
||||
@ -38,8 +38,7 @@ public class ByeGame extends Game{
|
||||
|
||||
|
||||
@Override
|
||||
public List<Game> getAllGames()
|
||||
{
|
||||
public List<Game> getAllGames() {
|
||||
List<Game> temp = new ArrayList<>();
|
||||
temp.add(this);
|
||||
temp.addAll(ref.getAllGames());
|
||||
|
@ -3,6 +3,7 @@ package tournament;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Game {
|
||||
|
||||
private static int counter = 0;
|
||||
protected final int id;
|
||||
//null nicht notwendig
|
||||
@ -43,9 +44,8 @@ public abstract class Game {
|
||||
|
||||
public abstract List<Game> getAllGames();
|
||||
|
||||
public String toString(){
|
||||
public String toString() {
|
||||
return "Game: " + getId() + " Player: "+ getPlayer1()+ " vs Player: " + getPlayer2() + "Winner is: "+ getWinner();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -5,45 +5,46 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class OrdinaryGame extends Game{
|
||||
|
||||
private Game Player1;
|
||||
private Game Player2;
|
||||
public OrdinaryGame(Game Player1, Game Player2)
|
||||
{
|
||||
|
||||
public OrdinaryGame(Game Player1, Game Player2) {
|
||||
this.Player1 = Player1;
|
||||
this.Player2 = Player2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayer1()
|
||||
{
|
||||
public String getPlayer1() {
|
||||
return Player1.getWinner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayer2()
|
||||
{
|
||||
public String getPlayer2() {
|
||||
return Player2.getWinner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllPlayers()
|
||||
{
|
||||
List<String> temp = new ArrayList();
|
||||
public List<String> getAllPlayers() {
|
||||
List<String> temp = new ArrayList<>();
|
||||
temp.addAll(Player1.getAllPlayers());
|
||||
temp.addAll(Player2.getAllPlayers());
|
||||
return temp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRemaningPlayers()
|
||||
{
|
||||
public List<String> getRemaningPlayers() {
|
||||
if(this.getWinner() != null)
|
||||
return new ArrayList<>(Arrays.asList(this.getWinner()));
|
||||
List<String> temp = new ArrayList();
|
||||
List<String> temp = new ArrayList<>();
|
||||
temp.addAll(Player1.getRemaningPlayers());
|
||||
temp.addAll(Player2.getRemaningPlayers());
|
||||
return temp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Game> getAllGames()
|
||||
{
|
||||
List<Game> temp = new ArrayList(Arrays.asList(this.getId()));
|
||||
public List<Game> getAllGames() {
|
||||
List<Game> temp = new ArrayList<>();
|
||||
temp.addAll(Player1.getAllGames());
|
||||
temp.addAll(Player2.getAllGames());
|
||||
return temp;
|
||||
|
@ -6,6 +6,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class SeededGame extends Game{
|
||||
|
||||
private String player1;
|
||||
private String player2;
|
||||
|
||||
@ -16,35 +17,32 @@ public class SeededGame extends Game{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayer1()
|
||||
{
|
||||
public String getPlayer1() {
|
||||
return player1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayer2()
|
||||
{
|
||||
public String getPlayer2() {
|
||||
return player2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllPlayers()
|
||||
{
|
||||
public List<String> getAllPlayers() {
|
||||
//return new ArrayList<String>(Arrays.asList(player1, player2));
|
||||
return List.of(player1, player2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRemaningPlayers()
|
||||
{
|
||||
if(this.getWinner() != null)
|
||||
public List<String> getRemaningPlayers() {
|
||||
if(this.getWinner() != null) {
|
||||
return new ArrayList<>(Arrays.asList(this.getWinner()));
|
||||
List<String> temp = new ArrayList(Arrays.asList(player1,player2));
|
||||
return temp;
|
||||
}
|
||||
|
||||
return List.of(player1, player2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Game> getAllGames()
|
||||
{
|
||||
public List<Game> getAllGames() {
|
||||
return List.of(this);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user