From cbeca1b3c01948185a61d01b9c1f905dfa6e44a3 Mon Sep 17 00:00:00 2001 From: peet Date: Mon, 6 May 2024 22:26:56 +0200 Subject: [PATCH] started on uebung04 --- bin/uebung04/ByeGame.class | Bin 909 -> 925 bytes bin/uebung04/Game.class | Bin 988 -> 1090 bytes bin/uebung04/OrdinaryGame.class | Bin 939 -> 1560 bytes bin/uebung04/SeededGame.class | Bin 927 -> 1319 bytes src/uebung04/ByeGame.java | 16 ++++++++++++++++ src/uebung04/Game.java | 15 ++++++++------- src/uebung04/OrdinaryGame.java | 27 +++++++++++++++++++++++++++ src/uebung04/SeededGame.java | 31 +++++++++++++++++++++++++++++++ 8 files changed, 82 insertions(+), 7 deletions(-) diff --git a/bin/uebung04/ByeGame.class b/bin/uebung04/ByeGame.class index 5ffee6329a6a04689cd004b57b6fe347b961b295..77308b2532ddd7cc613c11bee51216425ca69643 100644 GIT binary patch literal 925 zcmb_aOK%fF4EBVO$C5TBl=o#SaY!W80P3klNCg3x2q97`ah&Wr*@4}e)r>bHzkwfw z1QOi&Q3%gwDUU{+xL6+B^Vy&Mef$3D3jiF$?KU(7?36ew&Enp{`0)y#s~p?V6tHy` z4Iu&TB2z1L_XP|lZ`D$bGi4UzDLHKxM*><8wbArQz@6dw^yCk$qtU5=<`bK6qe}w% zztEmKXI%%jg!u5>m!71~3obxI zk~ptTicS-wsF^3HVv;#hY7-e)?Jtmyv+QNX%nwKZ3v&(lpaKj7=Gy0q;`C6)${0&b z$t=;4oI9IWlSs01z00UOT^UmEC5B~4=1le-8h=+Nm?1Ic6g}H27p79 z(ltZvLu1ePS@WvHe{q&vR+W~;#gz5!_j#eb>N18y?-l%g~3o$Te=vZ z=`cvIZm}P9274gj0*hZj11>^~y$1Vj=&wvQ%AAN@C&7k)Yw!c<2m)W+s1~@xl i+pGKtuD~w8crkG8H-u2PM!3EKVS6LOP5#q>TR#B9=Kzxc literal 909 zcmcgqOHUgy5dItj2}>X$H$xQ##m-y>Qeiw->p~x`%>1?#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vgyN&pomj?vqc$gWoF% B8|wf7 literal 927 zcmc&yO>YxH41JTPO}exsq%Gec1E+*Tw?&+q3aLWCWrdJZDsh}-tz^*bOf)-N(VxYs zQjy@!k3x8w&=je?!o?oj&-Sy&KYyKl2XFw{KuutyqG4snJ1^4#QBL_gRZs(Uf%S_( zbP25NYpcU6fu(NmNTB}O<&6^ zkJeM^%rWJ1uZ`2P5MfjYnV?pQY1N?8lm z%g;~I{K}6S5|%LxPPoBxZ3bYy4zvYsqQ#z={EQJ1mwZF}Q>Sx^%^z&>N?6V-F#Zni XUWvbV4gSG3_=i{Fx$PCuv6Sk+ 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; + } }