From 743162ef154679d194fdb4d7ffc72f40838cffa8 Mon Sep 17 00:00:00 2001 From: Steffen Helmke Date: Mon, 10 Jan 2022 19:22:03 +0100 Subject: [PATCH] 4gewinnt: refactored actionListener --- .../java/de/tims/viergewinnt/ai/Logic.java | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/main/java/de/tims/viergewinnt/ai/Logic.java b/src/main/java/de/tims/viergewinnt/ai/Logic.java index 139df50..794d610 100644 --- a/src/main/java/de/tims/viergewinnt/ai/Logic.java +++ b/src/main/java/de/tims/viergewinnt/ai/Logic.java @@ -13,7 +13,12 @@ import javax.swing.JPanel; public class Logic { + int[][] board; + int currentPlayer; + public int playChip(int[][] playfield, int column, int player) { + + testForWin(playfield, player); return 0; } @@ -50,23 +55,11 @@ public class Logic { @Override public void actionPerformed(ActionEvent e) { - if(e.getSource() == buttons[0]) { - - } - if(e.getSource() == buttons[1]) { - - } - if(e.getSource() == buttons[2]) { - - } - if(e.getSource() == buttons[3]) { - - } - if(e.getSource() == buttons[4]) { - - } - if(e.getSource() == buttons[5]) { - + for(int i = 0; i < buttons.length; i++) { + if(e.getSource() == buttons[i]) { + playChip(board, i, currentPlayer); + break; + } } }