
-----------------------------------
Kevin
Thu May 28, 2009 6:15 pm

SOMEONE PLEASE HELP MEEE gr 12 java
-----------------------------------
my program is the game of othello. i need help its due tmrw im rushing it last minute. i know its wrong. but i need help. basically the method is suppost to check if the block above it is the oposite color and if it is check if the one above it is the same color as urs.
i know its a poor explanation but the problem is in the "Checkvalid" method.

-----------------------------------
Kevin
Thu May 28, 2009 6:16 pm

Re: SOMEONE PLEASE HELP MEEE gr 12 java
-----------------------------------
Heres the code:


// The "GameBoard" class.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class GameBoard extends Applet implements ActionListener
{

    int board[] [] = new int [10] [10];
    JFrame gameFrame;
    JPanel center;
    JButton button[] [] = new JButton [8] [8];
    boolean checkValid;

    public GameBoard ()
    {
        checkValid = false;
        for (int r = 0 ; r < 10 ; r++)
        {
            for (int c = 0 ; c < 10 ; c++)
            {
                board [r] [c] = 0;
            }
        }
        board [4] [4] = 1; // white
        board [4] [5] = 2; // black
        board [5] [5] = 1;
        board [5] [4] = 2;
        gameFrame = new JFrame ("OTHELLO");
        gameFrame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

        center = new JPanel ();
        center.setBackground (Color.BLACK);
        center.setLayout (new GridLayout (0, 8, 1, 1));

        ////////////////////////////////////////////////////////////

        button [0] [0] = new JButton (" ");
        button [0] [0].setBackground (Color.red);
        button [0] [0].setActionCommand ("button[0][0]");
        button [0] [0].addActionListener (this);

        button [0] [1] = new JButton (" ");
        button [0] [1].setBackground (Color.red);
        button [0] [1].setActionCommand ("button[0][1]");
        button [0] [1].addActionListener (this);

        button [0] [2] = new JButton (" ");
        button [0] [2].setBackground (Color.red);
        button [0] [2].setActionCommand ("button[0][2]");
        button [0] [2].addActionListener (this);

        button [0] [3] = new JButton (" ");
        button [0] [3].setBackground (Color.red);
        button [0] [3].setActionCommand ("button[0][3]");
        button [0] [3].addActionListener (this);

        button [0] [4] = new JButton (" ");
        button [0] [4].setBackground (Color.red);
        button [0] [4].setActionCommand ("button[0][4]");
        button [0] [4].addActionListener (this);

        button [0] [5] = new JButton (" ");
        button [0] [5].setBackground (Color.red);
        button [0] [5].setActionCommand ("button[0][5]");
        button [0] [5].addActionListener (this);

        button [0] [6] = new JButton (" ");
        button [0] [6].setBackground (Color.red);
        button [0] [6].setActionCommand ("button[0][6]");
        button [0] [6].addActionListener (this);

        button [0] [7] = new JButton (" ");
        button [0] [7].setBackground (Color.red);
        button [0] [7].setActionCommand ("button[0][7]");
        button [0] [7].addActionListener (this);

        ////////////////////////////////////////////////////

        button [1] [0] = new JButton (" ");
        button [1] [0].setBackground (Color.red);
        button [1] [0].setActionCommand ("button[1][0]");
        button [1] [0].addActionListener (this);

        button [1] [1] = new JButton (" ");
        button [1] [1].setBackground (Color.red);
        button [1] [1].setActionCommand ("button[1][1]");
        button [1] [1].addActionListener (this);

        button [1] [2] = new JButton (" ");
        button [1] [2].setBackground (Color.red);
        button [1] [2].setActionCommand ("button[1][2]");
        button [1] [2].addActionListener (this);

        button [1] [3] = new JButton (" ");
        button [1] [3].setBackground (Color.red);
        button [1] [3].setActionCommand ("button[1][3]");
        button [1] [3].addActionListener (this);

        button [1] [4] = new JButton (" ");
        button [1] [4].setBackground (Color.red);
        button [1] [4].setActionCommand ("button[1][4]");
        button [1] [4].addActionListener (this);

        button [1] [5] = new JButton (" ");
        button [1] [5].setBackground (Color.red);
        button [1] [5].setActionCommand ("button[1][5]");
        button [1] [5].addActionListener (this);

        button [1] [6] = new JButton (" ");
        button [1] [6].setBackground (Color.red);
        button [1] [6].setActionCommand ("button[1][6]");
        button [1] [6].addActionListener (this);

        button [1] [7] = new JButton (" ");
        button [1] [7].setBackground (Color.red);
        button [1] [7].setActionCommand ("button[1][7]");
        button [1] [7].addActionListener (this);

        ////////////////////////////////////////////////////

        button [2] [0] = new JButton (" ");
        button [2] [0].setBackground (Color.red);
        button [2] [0].setActionCommand ("button[2][0]");
        button [2] [0].addActionListener (this);

        button [2] [1] = new JButton (" ");
        button [2] [1].setBackground (Color.red);
        button [2] [1].setActionCommand ("button[2][1]");
        button [2] [1].addActionListener (this);

        button [2] [2] = new JButton (" ");
        button [2] [2].setBackground (Color.red);
        button [2] [2].setActionCommand ("button[2][2]");
        button [2] [2].addActionListener (this);

        button [2] [3] = new JButton (" ");
        button [2] [3].setBackground (Color.red);
        button [2] [3].setActionCommand ("button[2][3]");
        button [2] [3].addActionListener (this);

        button [2] [4] = new JButton (" ");
        button [2] [4].setBackground (Color.red);
        button [2] [4].setActionCommand ("button[2][4]");
        button [2] [4].addActionListener (this);

        button [2] [5] = new JButton (" ");
        button [2] [5].setBackground (Color.red);
        button [2] [5].setActionCommand ("button[2][5]");
        button [2] [5].addActionListener (this);

        button [2] [6] = new JButton (" ");
        button [2] [6].setBackground (Color.red);
        button [2] [6].setActionCommand ("button[2][6]");
        button [2] [6].addActionListener (this);

        button [2] [7] = new JButton (" ");
        button [2] [7].setBackground (Color.red);
        button [2] [7].setActionCommand ("button[2][7]");
        button [2] [7].addActionListener (this);

        ////////////////////////////////////////////////////

        button [3] [0] = new JButton (" ");
        button [3] [0].setBackground (Color.red);
        button [3] [0].setActionCommand ("button[3][0]");
        button [3] [0].addActionListener (this);

        button [3] [1] = new JButton (" ");
        button [3] [1].setBackground (Color.red);
        button [3] [1].setActionCommand ("button[3][1]");
        button [3] [1].addActionListener (this);

        button [3] [2] = new JButton (" ");
        button [3] [2].setBackground (Color.red);
        button [3] [2].setActionCommand ("button[3][2]");
        button [3] [2].addActionListener (this);

        button [3] [3] = new JButton (" ");
        button [3] [3].setBackground (Color.white);

        button [3] [4] = new JButton (" ");
        button [3] [4].setBackground (Color.black);

        button [3] [5] = new JButton (" ");
        button [3] [5].setBackground (Color.red);
        button [3] [5].setActionCommand ("button[3][5]");
        button [3] [5].addActionListener (this);

        button [3] [6] = new JButton (" ");
        button [3] [6].setBackground (Color.red);
        button [3] [6].setActionCommand ("button[3][6]");
        button [3] [6].addActionListener (this);

        button [3] [7] = new JButton (" ");
        button [3] [7].setBackground (Color.red);
        button [3] [7].setActionCommand ("button[3][7]");
        button [3] [7].addActionListener (this);

        ////////////////////////////////////////////////////

        button [4] [0] = new JButton (" ");
        button [4] [0].setBackground (Color.red);
        button [4] [0].setActionCommand ("button[4][0]");
        button [4] [0].addActionListener (this);

        button [4] [1] = new JButton (" ");
        button [4] [1].setBackground (Color.red);
        button [4] [1].setActionCommand ("button[4][1]");
        button [4] [1].addActionListener (this);

        button [4] [2] = new JButton (" ");
        button [4] [2].setBackground (Color.red);
        button [4] [2].setActionCommand ("button[4][2]");
        button [4] [2].addActionListener (this);

        button [4] [3] = new JButton (" ");
        button [4] [3].setBackground (Color.black);

        button [4] [4] = new JButton (" ");
        button [4] [4].setBackground (Color.white);

        button [4] [5] = new JButton (" ");
        button [4] [5].setBackground (Color.red);
        button [4] [5].setActionCommand ("button[4][5]");
        button [4] [5].addActionListener (this);

        button [4] [6] = new JButton (" ");
        button [4] [6].setBackground (Color.red);
        button [4] [6].setActionCommand ("button[4][6]");
        button [4] [6].addActionListener (this);

        button [4] [7] = new JButton (" ");
        button [4] [7].setBackground (Color.red);
        button [4] [7].setActionCommand ("button[4][7]");
        button [4] [7].addActionListener (this);

        ////////////////////////////////////////////////////

        button [5] [0] = new JButton (" ");
        button [5] [0].setBackground (Color.red);
        button [5] [0].setActionCommand ("button[5][0]");
        button [5] [0].addActionListener (this);

        button [5] [1] = new JButton (" ");
        button [5] [1].setBackground (Color.red);
        button [5] [1].setActionCommand ("button[5][1]");
        button [5] [1].addActionListener (this);

        button [5] [2] = new JButton (" ");
        button [5] [2].setBackground (Color.red);
        button [5] [2].setActionCommand ("button[5][2]");
        button [5] [2].addActionListener (this);

        button [5] [3] = new JButton (" ");
        button [5] [3].setBackground (Color.red);
        button [5] [3].setActionCommand ("button[5][3]");
        button [5] [3].addActionListener (this);

        button [5] [4] = new JButton (" ");
        button [5] [4].setBackground (Color.red);
        button [5] [4].setActionCommand ("button[5][4]");
        button [5] [4].addActionListener (this);

        button [5] [5] = new JButton (" ");
        button [5] [5].setBackground (Color.red);
        button [5] [5].setActionCommand ("button[5][5]");
        button [5] [5].addActionListener (this);

        button [5] [6] = new JButton (" ");
        button [5] [6].setBackground (Color.red);
        button [5] [6].setActionCommand ("button[5][6]");
        button [5] [6].addActionListener (this);

        button [5] [7] = new JButton (" ");
        button [5] [7].setBackground (Color.red);
        button [5] [7].setActionCommand ("button[5][7]");
        button [5] [7].addActionListener (this);

        ////////////////////////////////////////////////////

        button [6] [0] = new JButton (" ");
        button [6] [0].setBackground (Color.red);
        button [6] [0].setActionCommand ("button[6][0]");
        button [6] [0].addActionListener (this);

        button [6] [1] = new JButton (" ");
        button [6] [1].setBackground (Color.red);
        button [6] [1].setActionCommand ("button[6][1]");
        button [6] [1].addActionListener (this);

        button [6] [2] = new JButton (" ");
        button [6] [2].setBackground (Color.red);
        button [6] [2].setActionCommand ("button[6][2]");
        button [6] [2].addActionListener (this);

        button [6] [3] = new JButton (" ");
        button [6] [3].setBackground (Color.red);
        button [6] [3].setActionCommand ("button[6][3]");
        button [6] [3].addActionListener (this);

        button [6] [4] = new JButton (" ");
        button [6] [4].setBackground (Color.red);
        button [6] [4].setActionCommand ("button[6][4]");
        button [6] [4].addActionListener (this);

        button [6] [5] = new JButton (" ");
        button [6] [5].setBackground (Color.red);
        button [6] [5].setActionCommand ("button[6][5]");
        button [6] [5].addActionListener (this);

        button [6] [6] = new JButton (" ");
        button [6] [6].setBackground (Color.red);
        button [6] [6].setActionCommand ("button[6][6]");
        button [6] [6].addActionListener (this);

        button [6] [7] = new JButton (" ");
        button [6] [7].setBackground (Color.red);
        button [6] [7].setActionCommand ("button[6][7]");
        button [6] [7].addActionListener (this);

        ////////////////////////////////////////////////////

        button [7] [0] = new JButton (" ");
        button [7] [0].setBackground (Color.red);
        button [7] [0].setActionCommand ("button[7][0]");
        button [7] [0].addActionListener (this);

        button [7] [1] = new JButton (" ");
        button [7] [1].setBackground (Color.red);
        button [7] [1].setActionCommand ("button[7][1]");
        button [7] [1].addActionListener (this);

        button [7] [2] = new JButton (" ");
        button [7] [2].setBackground (Color.red);
        button [7] [2].setActionCommand ("button[7][2]");
        button [7] [2].addActionListener (this);

        button [7] [3] = new JButton (" ");
        button [7] [3].setBackground (Color.red);
        button [7] [3].setActionCommand ("button[7][3]");
        button [7] [3].addActionListener (this);

        button [7] [4] = new JButton (" ");
        button [7] [4].setBackground (Color.red);
        button [7] [4].setActionCommand ("button[7][4]");
        button [7] [4].addActionListener (this);

        button [7] [5] = new JButton (" ");
        button [7] [5].setBackground (Color.red);
        button [7] [5].setActionCommand ("button[7][5]");
        button [7] [5].addActionListener (this);

        button [7] [6] = new JButton (" ");
        button [7] [6].setBackground (Color.red);
        button [7] [6].setActionCommand ("button[7][6]");
        button [7] [6].addActionListener (this);

        button [7] [7] = new JButton (" ");
        button [7] [7].setBackground (Color.red);
        button [7] [7].setActionCommand ("button[7][7]");
        button [7] [7].addActionListener (this);

        ////////////////////////////////////////////////////
        for (int i = 0 ; i 