Java Assignment
import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Lab11Shell extends JFrame { // this holds the current game board private char[][] gameBoard = new char[7][8]; private JButton[][] gameButtons = new JButton[7][8]; private ImageIcon red = new ImageIcon("Red.jpg"); private ImageIcon black = new ImageIcon("Black.jpg"); private ImageIcon empty = new ImageIcon("Empty.jpg"); private JPanel panel = new JPanel(); private int currentPlayer = 1; private int numMoves = 0; public Lab11Shell() { // set layout on panel // loop through buttons array creating buttons, registering event handlers and adding buttons to panel // add panel to frame // do other initialization of applet } public static void main(String args[]) { Lab11Shell game = new Lab11Shell(); } class ButtonListener implements ActionListener { public void actionPerformed(ActionEvent e) { // loop through button array // if this is button pressed and column is valid move // call MakeMove method // break } } void MakeMove(int col) { // place piece on both arrays // if winner (I recommend making this a method call) if (CheckForWin()) // display congratulations // if user wants to play again if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, "Do you want to play again", "Play again", JOptionPane.YES_NO_OPTION)) // reset game // else // exit System.exit(0); // else if tie // display tie // if user wants to play again // reset game // else // exit System.exit(0); // else // switch currentPlayer // increment numMoves } void ResetGame() { // loop through both arrays setting char array back to ' ' and buttons array back to empty pic // reset currentPlayer and numMoves variables } boolean CheckForWin() { } }