diff --git a/Tic-Tac-Toe/Spieler.class b/Tic-Tac-Toe/Spieler.class index 3820a08..4f1d609 100644 Binary files a/Tic-Tac-Toe/Spieler.class and b/Tic-Tac-Toe/Spieler.class differ diff --git a/Tic-Tac-Toe/Spieler.ctxt b/Tic-Tac-Toe/Spieler.ctxt index 7811ac9..ab29caf 100644 --- a/Tic-Tac-Toe/Spieler.ctxt +++ b/Tic-Tac-Toe/Spieler.ctxt @@ -3,21 +3,25 @@ comment0.target=Spieler comment1.params=pName comment1.target=Spieler(java.lang.String) comment10.params= -comment10.target=int\ getRundenAnzahl() +comment10.target=int\ getSiege() +comment11.params= +comment11.target=int\ getNiederlagen() +comment12.params= +comment12.target=int\ getRundenAnzahl() comment2.params= comment2.target=int[]\ spielzug() comment3.params= comment3.target=double\ siegesrateBestimmen() -comment4.params=pSiege -comment4.target=void\ setSiege(int) -comment5.params=pNiederlagen -comment5.target=void\ setNiederlagen(int) -comment6.params=pRundenAnzahl -comment6.target=void\ setRundenAnzahl(int) -comment7.params= -comment7.target=java.lang.String\ getName() -comment8.params= -comment8.target=int\ getSiege() +comment4.params= +comment4.target=void\ sieg() +comment5.params= +comment5.target=void\ niederlage() +comment6.params=pSiege +comment6.target=void\ setSiege(int) +comment7.params=pNiederlagen +comment7.target=void\ setNiederlagen(int) +comment8.params=pRundenAnzahl +comment8.target=void\ setRundenAnzahl(int) comment9.params= -comment9.target=int\ getNiederlagen() -numComments=11 +comment9.target=java.lang.String\ getName() +numComments=13 diff --git a/Tic-Tac-Toe/TicTacToe.class b/Tic-Tac-Toe/TicTacToe.class index 1f2eff9..b7bedb3 100644 Binary files a/Tic-Tac-Toe/TicTacToe.class and b/Tic-Tac-Toe/TicTacToe.class differ diff --git a/Tic-Tac-Toe/TicTacToe.ctxt b/Tic-Tac-Toe/TicTacToe.ctxt index e0bf78d..ce818fa 100644 --- a/Tic-Tac-Toe/TicTacToe.ctxt +++ b/Tic-Tac-Toe/TicTacToe.ctxt @@ -1,11 +1,11 @@ #BlueJ class context comment0.target=TicTacToe -comment1.params= -comment1.target=TicTacToe() -comment2.params=sp1name\ sp2name -comment2.target=void\ spielErstellen(java.lang.String,\ java.lang.String) +comment1.params=sp1name\ sp2name +comment1.target=TicTacToe(java.lang.String,\ java.lang.String) +comment2.params= +comment2.target=void\ druckeSpielfeld() comment3.params= -comment3.target=void\ druckeSpielfeld() +comment3.target=void\ spielStarten() comment4.params= -comment4.target=void\ spielStarten() +comment4.target=boolean\ spielVorbei() numComments=5 diff --git a/Tic-Tac-Toe/TicTacToe.java b/Tic-Tac-Toe/TicTacToe.java index f626a13..4289a10 100644 --- a/Tic-Tac-Toe/TicTacToe.java +++ b/Tic-Tac-Toe/TicTacToe.java @@ -8,16 +8,14 @@ public class TicTacToe { Random rand = new Random(); Spieler spieler1; Spieler spieler2; - public TicTacToe() { + public TicTacToe(String sp1name, String sp2name) { spielfeld = new String[3][3]; running = false; + spieler1 = new Spieler(sp1name); + spieler2 = new Spieler(sp2name); } - public void spielErstellen(String sp1name,String sp2name){ - Spieler spieler1 = new Spieler(sp1name); - Spieler spieler2 = new Spieler(sp2name); - - } + public void druckeSpielfeld(){ System.out.println (" "); @@ -62,14 +60,22 @@ public class TicTacToe { System.out.println("Tippe zuerst X Koordinate, dann Y Koordinate von unten links!"); kord=spieler2.spielzug(); spielfeld[kord[0]-1][kord[1]-1]="X"; - spielVorbei(); + if(spielVorbei()){ + spieler1.sieg(); + spieler2.niederlage(); + return; + } //Spieler1 am Zug druckeSpielfeld(); System.out.println(spieler1.getName()+" ist an der Reihe!"); System.out.println("Tippe zuerst X Koordinate, dann Y Koordinate von unten links!"); kord=spieler1.spielzug(); spielfeld[kord[0]-1][kord[1]-1]="O"; - spielVorbei(); + if(spielVorbei()){ + spieler2.sieg(); + spieler1.niederlage(); + return; + } } }