started on uebung04
This commit is contained in:
parent
7ac35f607a
commit
cbeca1b3c0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,4 +2,20 @@ package uebung04;
|
|||||||
|
|
||||||
public class ByeGame extends Game{
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
package uebung04;
|
package uebung04;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public abstract class Game {
|
public abstract class Game {
|
||||||
|
|
||||||
protected static int counter = 0;
|
protected static int counter = 0;
|
||||||
protected final int id;
|
protected final int id;
|
||||||
protected String player1;
|
protected T player1 = null;
|
||||||
protected String player2;
|
protected String player2 = null;
|
||||||
protected String winner;
|
protected String winner = null;
|
||||||
|
|
||||||
public Game(){
|
protected Game(){
|
||||||
id = counter;
|
id = counter;
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {return id;}
|
public int getId() {return id;}
|
||||||
|
|
||||||
public String getWinner(){return winner;}
|
protected String getWinner(){return winner;}
|
||||||
|
|
||||||
public void setWinner(int player){
|
public void setWinner(int player){
|
||||||
if (player == 1) {
|
if (player == 1) {
|
||||||
@ -28,7 +28,8 @@ public abstract class Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getPlayer1();
|
public abstract String getPlayer1();
|
||||||
|
|
||||||
public abstract String getPlayer2();
|
public abstract String getPlayer2();
|
||||||
|
|
||||||
public abstract List<String> getAllPlayers();
|
public abstract ArrayList<String> getAllPlayers();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,32 @@
|
|||||||
package uebung04;
|
package uebung04;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class OrdinaryGame extends Game{
|
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<String> getPlayer1(){
|
||||||
|
return player1.getAllPlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> getPlayer2(){
|
||||||
|
return player2.getAllPlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> getAllPlayers(){
|
||||||
|
ArrayList<String> rtn = player1.getAllPlayers();
|
||||||
|
rtn.addAll(player2.getAllPlayers());
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,36 @@
|
|||||||
package uebung04;
|
package uebung04;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class SeededGame extends Game{
|
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<String> getAllPlayers(){
|
||||||
|
ArrayList<String> e = new ArrayList<String>();
|
||||||
|
e.add(player1);
|
||||||
|
e.add(player2);
|
||||||
|
return e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user