44 lines
1.4 KiB
Java
44 lines
1.4 KiB
Java
import javax.swing.JFrame;
|
|
import java.awt.*;
|
|
|
|
/**
|
|
* Main program layout
|
|
*/
|
|
public class Chess {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
JFrame okno = new JFrame();
|
|
okno.setTitle("Filip Znachor, A22B0042P");
|
|
okno.setSize(800, 600);
|
|
okno.setMinimumSize(new Dimension(800, 600));
|
|
|
|
Chessboard chessboard = new Chessboard();
|
|
|
|
PieceColor[] colors = new PieceColor[]{PieceColor.BLACK, PieceColor.WHITE};
|
|
for (int i = 0; i < colors.length; i++) {
|
|
int first = i == 0 ? 7 : 0;
|
|
int second = i == 0 ? 6 : 1;
|
|
new Rook(chessboard, 0, first, colors[i]);
|
|
new Knight(chessboard, 1, first, colors[i]);
|
|
new Rook(chessboard, 7, first, colors[i]);
|
|
new Knight(chessboard, 6, first, colors[i]);
|
|
new Queen(chessboard, 4, first, colors[i]);
|
|
new Bishop(chessboard, 5, first, colors[i]);
|
|
new Bishop(chessboard, 2, first, colors[i]);
|
|
new King(chessboard, 3, first, colors[i]);
|
|
for (int j = 0; j < 8; j++) {
|
|
new Pawn(chessboard, j, second, colors[i]);
|
|
}
|
|
}
|
|
|
|
okno.add(chessboard); //prida komponentu
|
|
okno.pack(); //udela resize okna dle komponent
|
|
|
|
okno.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
okno.setLocationRelativeTo(null); //vycentrovat na obrazovce
|
|
okno.setVisible(true);
|
|
|
|
}
|
|
|
|
} |