method checkForWin implemented
This commit is contained in:
parent
8d9eac4a40
commit
96a94aa12d
|
@ -64,4 +64,31 @@ public class Game {
|
|||
public void changeLanguage(String language) {
|
||||
this.language.setOutputLanguage(language);
|
||||
}
|
||||
public boolean checkForWin() {
|
||||
if((gamefield.getField(1) == gamefield.getField(2)) && (gamefield.getField(3) == gamefield.getField(1))){
|
||||
return true;
|
||||
}
|
||||
else if((gamefield.getField(4) == gamefield.getField(5)) && (gamefield.getField(6) == gamefield.getField(4))){
|
||||
return true;
|
||||
}
|
||||
else if((gamefield.getField(7) == gamefield.getField(8)) && (gamefield.getField(9) == gamefield.getField(7))){
|
||||
return true;
|
||||
}
|
||||
else if((gamefield.getField(1) == gamefield.getField(4)) && (gamefield.getField(7) == gamefield.getField(1))){
|
||||
return true;
|
||||
}
|
||||
else if((gamefield.getField(2) == gamefield.getField(5)) && (gamefield.getField(8) == gamefield.getField(2))){
|
||||
return true;
|
||||
}
|
||||
else if((gamefield.getField(3) == gamefield.getField(6)) && (gamefield.getField(9) == gamefield.getField(3))){
|
||||
return true;
|
||||
}
|
||||
else if((gamefield.getField(1) == gamefield.getField(5)) && (gamefield.getField(9) == gamefield.getField(1))){
|
||||
return true;
|
||||
}
|
||||
else if((gamefield.getField(3) == gamefield.getField(5)) && (gamefield.getField(7) == gamefield.getField(3))){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue