2020-02-13 19:46:00 +01:00
|
|
|
/*
|
|
|
|
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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-02-05 15:01:40 +01:00
|
|
|
package de.itsblue.ConnectFour;
|
|
|
|
|
2020-02-11 21:46:24 +01:00
|
|
|
|
2020-02-14 19:21:49 +01:00
|
|
|
import java.awt.*;
|
|
|
|
import javax.swing.*;
|
2020-02-05 15:01:40 +01:00
|
|
|
|
2020-02-12 15:01:51 +01:00
|
|
|
import de.itsblue.ConnectFour.GameBoard;
|
2020-02-13 19:24:32 +01:00
|
|
|
import de.itsblue.ConnectFour.Plate.PlateType;
|
2020-02-12 15:01:51 +01:00
|
|
|
|
2020-02-05 15:01:40 +01:00
|
|
|
public class ConnectFour extends JFrame {
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2020-02-16 19:46:57 +01:00
|
|
|
private static final long serialVersionUID = 1L;
|
2020-02-12 15:01:51 +01:00
|
|
|
|
2020-02-05 15:01:40 +01:00
|
|
|
ConnectFour() {
|
|
|
|
// Constructor
|
|
|
|
|
2020-02-11 21:46:24 +01:00
|
|
|
// initialize window
|
|
|
|
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
2020-02-12 15:30:59 +01:00
|
|
|
this.setTitle("Connect 4");
|
2020-02-12 15:01:51 +01:00
|
|
|
|
2020-02-11 21:46:24 +01:00
|
|
|
this.setPreferredSize(new Dimension(600, 600));
|
2020-02-05 15:29:52 +01:00
|
|
|
|
2020-02-14 19:21:49 +01:00
|
|
|
this.getContentPane().setLayout(new GridBagLayout());
|
|
|
|
|
2020-02-12 15:01:51 +01:00
|
|
|
GameBoard board = new GameBoard();
|
2020-02-16 19:46:57 +01:00
|
|
|
board.setPreferredSize(new Dimension(200,200));
|
2020-02-12 15:01:51 +01:00
|
|
|
this.add(board);
|
|
|
|
|
2020-02-14 19:21:49 +01:00
|
|
|
for(int i = 0; i < 7; i++) {
|
|
|
|
board.insertPlate(new Plate(PlateType.X), i);
|
|
|
|
}
|
|
|
|
|
|
|
|
board.insertPlate(new Plate(PlateType.O), 1);
|
2020-02-13 19:24:32 +01:00
|
|
|
|
2020-02-05 15:01:40 +01:00
|
|
|
// finish up
|
|
|
|
this.pack();
|
|
|
|
this.setVisible(true);
|
|
|
|
}
|
|
|
|
|
2020-02-05 15:29:52 +01:00
|
|
|
public static void main(final String[] args) {
|
2020-02-05 15:01:40 +01:00
|
|
|
System.out.println(new ConnectFour());
|
|
|
|
}
|
|
|
|
}
|