spielStarten() weitergemacht

while()
This commit is contained in:
artem.didytschuk
2020-09-03 18:03:29 +02:00
parent 04d0a80dce
commit a45e83fbf2
3 changed files with 21 additions and 7 deletions

Binary file not shown.

View File

@@ -5,5 +5,9 @@ comment1.target=TicTacToe()
comment2.params=sp1name\ sp2name comment2.params=sp1name\ sp2name
comment2.target=void\ spielErstellen(java.lang.String,\ java.lang.String) comment2.target=void\ spielErstellen(java.lang.String,\ java.lang.String)
comment3.params= comment3.params=
comment3.target=void\ spielStarten() comment3.target=void\ druckeSpielfeld()
numComments=4 comment4.params=
comment4.target=void\ spielStarten()
comment5.params=
comment5.target=boolean\ spielVorbei()
numComments=6

View File

@@ -3,13 +3,13 @@ import java.util.Random;
public class TicTacToe { public class TicTacToe {
int [][] spielfeld; char [][] spielfeld;
boolean running; boolean running;
Random rand = new Random(); Random rand = new Random();
Spieler spieler1; Spieler spieler1;
Spieler spieler2; Spieler spieler2;
public TicTacToe() { public TicTacToe() {
spielfeld = new int[3][3]; spielfeld = new char[3][3];
running = false; running = false;
} }
@@ -28,16 +28,26 @@ public class TicTacToe {
int kord[]; int kord[];
for(int i =0;i< spielfeld.length;i++){ for(int i =0;i< spielfeld.length;i++){
for(int j=0;j<spielfeld[i].length;j++){ for(int j=0;j<spielfeld[i].length;j++){
spielfeld[i][j]=0; spielfeld[i][j]=' ';
} }
} }
if(rand.nextInt(2)==0){ if(rand.nextInt(2)==0){
while(gewonnen==false){ while(gewonnen==false){
druckeSpielfeld(); druckeSpielfeld();
kord=spieler1.spielzug(); kord=spieler1.spielzug();
spielfeld[kord[0]][kord[1]]=1; spielfeld[kord[0]][kord[1]]='X';
spielVorbei();
druckeSpielfeld();
kord=spieler2.spielzug();
spielfeld[kord[0]][kord[1]]='O';
spielVorbei();
} }
} }
} }
//prüft ob ein Spieler gewonnen hat
private boolean spielVorbei(){
//TODO
return false;
}
} }