diff --git a/bin/uebung04/ByeGame.class b/bin/uebung04/ByeGame.class index 5ffee63..77308b2 100644 Binary files a/bin/uebung04/ByeGame.class and b/bin/uebung04/ByeGame.class differ diff --git a/bin/uebung04/Game.class b/bin/uebung04/Game.class index 23188ba..ae8a17d 100644 Binary files a/bin/uebung04/Game.class and b/bin/uebung04/Game.class differ diff --git a/bin/uebung04/OrdinaryGame.class b/bin/uebung04/OrdinaryGame.class index 3f6c366..9a85dd3 100644 Binary files a/bin/uebung04/OrdinaryGame.class and b/bin/uebung04/OrdinaryGame.class differ diff --git a/bin/uebung04/SeededGame.class b/bin/uebung04/SeededGame.class index 654c041..a0d7186 100644 Binary files a/bin/uebung04/SeededGame.class and b/bin/uebung04/SeededGame.class differ diff --git a/src/uebung04/ByeGame.java b/src/uebung04/ByeGame.java index 8e3d079..dbb47f1 100644 --- a/src/uebung04/ByeGame.java +++ b/src/uebung04/ByeGame.java @@ -1,5 +1,21 @@ package uebung04; public class ByeGame extends Game{ + + private String player1; + + + public ByeGame(String player1, Game player2){ + this.player1 = player1; + this.player2 = player2; + + } + + public String getPlayer1(){return player1;} + + public ??? getPlayer2(){ + return player2.getAllPlayers(); + } + } diff --git a/src/uebung04/Game.java b/src/uebung04/Game.java index 6754036..6f263be 100644 --- a/src/uebung04/Game.java +++ b/src/uebung04/Game.java @@ -1,23 +1,23 @@ package uebung04; -import java.util.List; +import java.util.ArrayList; public abstract class Game { protected static int counter = 0; protected final int id; - protected String player1; - protected String player2; - protected String winner; + protected T player1 = null; + protected String player2 = null; + protected String winner = null; - public Game(){ + protected Game(){ id = counter; counter++; } public int getId() {return id;} - public String getWinner(){return winner;} + protected String getWinner(){return winner;} public void setWinner(int player){ if (player == 1) { @@ -28,7 +28,8 @@ public abstract class Game { } public abstract String getPlayer1(); + public abstract String getPlayer2(); - public abstract List getAllPlayers(); + public abstract ArrayList getAllPlayers(); } diff --git a/src/uebung04/OrdinaryGame.java b/src/uebung04/OrdinaryGame.java index f7d6b3e..3d718aa 100644 --- a/src/uebung04/OrdinaryGame.java +++ b/src/uebung04/OrdinaryGame.java @@ -1,5 +1,32 @@ package uebung04; +import java.util.ArrayList; + public class OrdinaryGame extends Game{ + + private final int id; + + + public OrdinaryGame(Game player1, Game player2){ + this.player1 = player1; + this.player2 = player2; + + id = counter; + counter++; + } + + public ArrayList getPlayer1(){ + return player1.getAllPlayers(); + } + + public ArrayList getPlayer2(){ + return player2.getAllPlayers(); + } + + public ArrayList getAllPlayers(){ + ArrayList rtn = player1.getAllPlayers(); + rtn.addAll(player2.getAllPlayers()); + return rtn; + } } diff --git a/src/uebung04/SeededGame.java b/src/uebung04/SeededGame.java index 89852d4..68c404e 100644 --- a/src/uebung04/SeededGame.java +++ b/src/uebung04/SeededGame.java @@ -1,5 +1,36 @@ package uebung04; +import java.util.ArrayList; + public class SeededGame extends Game{ + + private String player1; + private String player2; + private int id; + + public SeededGame(String player1, String player2){ + this.player1 = player1; + this.player2 = player2; + // super(); + id = counter; + counter++; + } + @Override + public String getPlayer1(){ + return player1; + } + + @Override + public String getPlayer2(){ + return player2; + } + + @Override + public ArrayList getAllPlayers(){ + ArrayList e = new ArrayList(); + e.add(player1); + e.add(player2); + return e; + } }