Format code
This commit is contained in:
parent
c70ec31da6
commit
bfb89267b7
@ -13,6 +13,7 @@ import javax.swing.JPanel;
|
|||||||
* @author aNNiMON
|
* @author aNNiMON
|
||||||
*/
|
*/
|
||||||
public class GameBoard extends JPanel {
|
public class GameBoard extends JPanel {
|
||||||
|
|
||||||
private static final int CELL_SIZE = 150;
|
private static final int CELL_SIZE = 150;
|
||||||
private static final int OFFSET = 15;
|
private static final int OFFSET = 15;
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ public class Main extends JFrame {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new Main().setVisible(true);
|
new Main().setVisible(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Main() {
|
public Main() {
|
||||||
|
@ -44,7 +44,7 @@ public class Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFigure(int x, int y) {
|
public void setFigure(int x, int y) {
|
||||||
if( (checkWinner() != Figure.EMPTY) || (!hasMoreMoves()) ) {
|
if ( (checkWinner() != Figure.EMPTY) || (!hasMoreMoves()) ) {
|
||||||
resetTable();
|
resetTable();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ public class Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void computerMove() {
|
public void computerMove() {
|
||||||
if( (checkWinner() != Figure.EMPTY) || (!hasMoreMoves()) ) {
|
if ( (checkWinner() != Figure.EMPTY) || (!hasMoreMoves()) ) {
|
||||||
//resetTable();
|
//resetTable();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -105,14 +105,14 @@ public class Table {
|
|||||||
|
|
||||||
// Trying to put figure to the center.
|
// Trying to put figure to the center.
|
||||||
int x = 1, y = 1;
|
int x = 1, y = 1;
|
||||||
if(!table[y][x].isEmpty() || (random.nextInt(5) <= 3) ) {
|
if (!table[y][x].isEmpty() || (random.nextInt(5) <= 3) ) {
|
||||||
// If it's busy, put to the corners.
|
// If it's busy, put to the corners.
|
||||||
int count = 0;
|
int count = 0;
|
||||||
do {
|
do {
|
||||||
x = random.nextBoolean() ? 0 : 2;
|
x = random.nextBoolean() ? 0 : 2;
|
||||||
y = random.nextBoolean() ? 0 : 2;
|
y = random.nextBoolean() ? 0 : 2;
|
||||||
count++;
|
count++;
|
||||||
} while ( (!table[y][x].isEmpty()) && (count < 10));
|
} while ( (!table[y][x].isEmpty()) && (count < 10) );
|
||||||
|
|
||||||
if (count > 9) {
|
if (count > 9) {
|
||||||
// Put to the remaining cells.
|
// Put to the remaining cells.
|
||||||
@ -122,7 +122,7 @@ public class Table {
|
|||||||
x = pair[random.nextInt(pair.length)][0];
|
x = pair[random.nextInt(pair.length)][0];
|
||||||
y = pair[random.nextInt(pair.length)][1];
|
y = pair[random.nextInt(pair.length)][1];
|
||||||
count++;
|
count++;
|
||||||
} while ( (!table[y][x].isEmpty()) && (count < 10));
|
} while ( (!table[y][x].isEmpty()) && (count < 10) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
table[y][x].setFigure(nextMoveIsX ? Figure.X : Figure.O);
|
table[y][x].setFigure(nextMoveIsX ? Figure.X : Figure.O);
|
||||||
|
@ -103,7 +103,6 @@ public class TitlePanel extends JPanel {
|
|||||||
});
|
});
|
||||||
setLayout(null);
|
setLayout(null);
|
||||||
|
|
||||||
|
|
||||||
final JButton exitButton = new JButton();
|
final JButton exitButton = new JButton();
|
||||||
exitButton.setIcon(new ImageIcon(exitImageBW));
|
exitButton.setIcon(new ImageIcon(exitImageBW));
|
||||||
exitButton.setBorder(null);
|
exitButton.setBorder(null);
|
||||||
@ -177,5 +176,4 @@ public class TitlePanel extends JPanel {
|
|||||||
mainFrame.setLocation(moved);
|
mainFrame.setLocation(moved);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -21,5 +21,4 @@ public class Util {
|
|||||||
}
|
}
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user