/* Connect four - written in java Copyright (C) 2020 Oliver Schappacher and Dorian Zedler This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ package de.itsblue.ConnectFour; import java.awt.*; import javax.swing.*; import de.itsblue.ConnectFour.GameBoard; import de.itsblue.ConnectFour.Plate.PlateType; public class ConnectFour extends JFrame { /** * */ private static final long serialVersionUID = 1L; ConnectFour() { // Constructor // initialize window this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setTitle("Connect 4"); this.setPreferredSize(new Dimension(600, 600)); this.getContentPane().setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridy = 0; // Board initilisieren ButtonRow buttonRow = new ButtonRow(7); buttonRow.setPreferredSize(new Dimension(400,20)); add(buttonRow,c); GameBoard board = new GameBoard(); board.setPreferredSize(new Dimension(400, 400)); c.gridy = 1; this.add(board, c); // plate in das Board einfügen board.insertPlate(new Plate(PlateType.O), 1); // ein paar mehr plates einfügen for (int i = 0; i < 7; i++) { String res = board.insertPlate(new Plate(PlateType.X), i); // wen das Rückgabewert weder "ok" noch "err" ist, hat jemand gewonnen if (res != "ok" && res != "err") System.out.println(PlateType.valueOf(res)); } // board kann mit board.clearBoard(); geleert werden. // finish up this.pack(); this.setVisible(true); } public static void main(final String[] args) { System.out.println(new ConnectFour()); } }