From 96a94aa12dffa05d494a7700efa12d97e5d09fb4 Mon Sep 17 00:00:00 2001 From: Leonardo Brandenberger Date: Thu, 7 Oct 2021 22:18:34 +0200 Subject: [PATCH] method checkForWin implemented --- src/Game.java | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/Game.java b/src/Game.java index 9891d99..391bba6 100644 --- a/src/Game.java +++ b/src/Game.java @@ -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; + } }