Commit 70b187ae authored by Stefano Cobelli's avatar Stefano Cobelli
Browse files

GUI finished, model.player package created

parent 5b100d94
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
*/ */
package model; package model;
import model.player.Player;
/** /**
* Board for the Tic Tac Toe * Board for the Tic Tac Toe
* *
......
...@@ -10,6 +10,7 @@ package model; ...@@ -10,6 +10,7 @@ package model;
import java.util.Scanner; import java.util.Scanner;
import model.Board.State; import model.Board.State;
import model.player.Player;
/** /**
* The actual game class * The actual game class
......
...@@ -10,6 +10,7 @@ package model; ...@@ -10,6 +10,7 @@ package model;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import model.Board.State; import model.Board.State;
import model.player.Player;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
......
...@@ -10,7 +10,10 @@ ...@@ -10,7 +10,10 @@
* @author sjc032 * @author sjc032
* *
*/ */
package model; package model.player;
import model.Board;
import model.Mark;
public class Player { public class Player {
/** reference to the current board */ /** reference to the current board */
......
/**
* CSCI 205 -Software Design and Engineering
* Name(s) Stefano Cobelli
*
* Work: hw02
* Created: Nov 11, 2014, 5:53:56 PM
*/
package view;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
/**
* @author sjc032
*
*/
public class TTTControlPanel extends JPanel {
private JButton newGameButton;
private JButton trainAIButton;
private JTextField trainNumberField;
public TTTControlPanel() {
this.setLayout(new GridLayout(1, 3, 5, 5));
this.setBorder(new EmptyBorder(5, 5, 5, 5));
this.newGameButton = new JButton("New Game");
this.trainAIButton = new JButton("Train AI");
this.trainNumberField = new JTextField("10000");
String[] gameModeOptions = { "Player vs. Computer", "Player vs. Player" };
this.add(this.newGameButton);
this.add(this.trainAIButton);
this.add(this.trainNumberField);
}
/**
* @return the newGameButton
*/
public JButton getNewGameButton() {
return newGameButton;
}
/**
* @return the trainAIButton
*/
public JButton getTrainAIButton() {
return trainAIButton;
}
/**
* @return the trainNumberField
*/
public JTextField getTrainNumberField() {
return trainNumberField;
}
}
\ No newline at end of file
...@@ -26,6 +26,7 @@ public class TTTMainView extends JFrame { ...@@ -26,6 +26,7 @@ public class TTTMainView extends JFrame {
/** the left side stat panel */ /** the left side stat panel */
private TTTStatsPanel statsPanel; private TTTStatsPanel statsPanel;
private TTTPlayerPanel playerPanel; private TTTPlayerPanel playerPanel;
private TTTControlPanel controlPanel;
/** /**
* The constructor of the frame of the GUI * The constructor of the frame of the GUI
...@@ -44,6 +45,8 @@ public class TTTMainView extends JFrame { ...@@ -44,6 +45,8 @@ public class TTTMainView extends JFrame {
this.add(boardPanel, BorderLayout.CENTER); this.add(boardPanel, BorderLayout.CENTER);
this.statsPanel = new TTTStatsPanel(); this.statsPanel = new TTTStatsPanel();
this.add(statsPanel, BorderLayout.WEST); this.add(statsPanel, BorderLayout.WEST);
this.controlPanel = new TTTControlPanel();
this.add(controlPanel, BorderLayout.SOUTH);
this.pack(); this.pack();
} }
......
...@@ -13,6 +13,7 @@ import java.awt.GridLayout; ...@@ -13,6 +13,7 @@ import java.awt.GridLayout;
import javax.swing.JComboBox; import javax.swing.JComboBox;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.EtchedBorder; import javax.swing.border.EtchedBorder;
/** /**
...@@ -29,15 +30,15 @@ public class TTTPlayerPanel extends JPanel { ...@@ -29,15 +30,15 @@ public class TTTPlayerPanel extends JPanel {
this.setLayout(new GridLayout(2, 2, 5, 5)); this.setLayout(new GridLayout(2, 2, 5, 5));
this.setBorder(new EtchedBorder(0, new Color(53, 178, 250), new Color( this.setBorder(new EtchedBorder(0, new Color(53, 178, 250), new Color(
73, 178, 250))); 73, 178, 250)));
JLabel gameModeText = new JLabel("Game Mode:"); JLabel gameModeText = new JLabel("Game Mode:", SwingConstants.CENTER);
JLabel aIText = new JLabel("Computer Player:"); JLabel aIText = new JLabel("Computer Player:", SwingConstants.CENTER);
String[] gameModeOptions = { "Player vs. Computer", "Player vs. Player" }; String[] gameModeOptions = { "Player vs. Computer", "Player vs. Player" };
this.gameModeComboBox = new JComboBox(gameModeOptions); this.gameModeComboBox = new JComboBox(gameModeOptions);
String[] aIOptions = { "Random", "Blocker", "AI Player" }; String[] aIOptions = { "Random", "Blocker", "AI Player" };
this.aIComboBox = new JComboBox(aIOptions); this.aIComboBox = new JComboBox(aIOptions);
this.add(gameModeText); this.add(gameModeText);
this.add(aIText);
this.add(gameModeComboBox); this.add(gameModeComboBox);
this.add(aIText);
this.add(aIComboBox); this.add(aIComboBox);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment