Go Back   Webmaster Centre News and Discussion Forum > Website Developement > Web Programming

Web Programming Post your questions, tips and opinions on web scripting, programming languages. Subject areas include Java, Java Script, PHP, ASP, .Net, XML, Perl, HTML, Flash,etc

Reply
 
LinkBack Thread Tools Display Modes
Old 04-29-2008, 09:48 AM   #1 (permalink)
Junior Member
 
Default Connect four in JAVA?!?

/**
*
* A 'Connect 4' board object represents the game board of
* the 'Connect 4' game. It consists of an 8 x 8 grid of
* spaces, where each space can contain either a red checker,
* a black checker, or no checker. The board can be thought
* of as being vertical, so checkers fill the grid squares
* from the bottom up.
*/
public interface Connect4Board
{
final static public int RED = -1;

final static public int NONE = 0;

final static public int BLACK = 1;

/**
* This method will clear the board's grid so that all spaces
* are marked as having 'no checker' in each space.
*/
public void clear();

/**
* This method adds a red checker to the specified column, if
* possible. (If this column is full, nothing happens.) If
* there is space in the column for another checker, then
* a red checker will be placed in the lowest unoccupied
* space in the column.
*
* Column 0 corresponds to the left side of the grid.
*
* @param column A column number, from 0 to 7.
*/
public void addRedChecker (int column);

/**
* This method adds a black checker to the specified column, if
* possible. (If this column is full, nothing happens.) If
* there is space in the column for another checker, then
* a black checker will be placed in the lowest unoccupied
* space in the column.
* <p>
*
* Column 0 corresponds to the left side of the grid.
*
* @param column A column number, from 0 to 7.
*/
public void addBlackChecker (int column);

/**
* This method removes the topmost checker from the specified
* column. If the column is empty, nothing happens.
*
* Column 0 corresponds to the left side of the grid.
*
* @param column A column number, from 0 to 7.
*/
public void removeChecker (int column);

/**
* Returns true if the board is full of checkers.
*
* @return true if the board is full of checkers.
*/
public boolean isFull ();

/**
* Returns an integer describing the checker in the specified
* space in the grid. Row 0 corresponds to the bottom
* of the grid, column 0 corresponds to the left side of the grid.
* <p>
*
* Returns the RED constant (defined above) if the space has
* a red checker in it, the BLACK constant (defined above) if the
* space has a black checker in it, and NONE (defined above) if
* there is no checker in the space.
* <p>
*
* If the row or column number is outside the range 0..7, this
* method will return NONE (defined above).
*
* @param row A row number, from 0 to 7.
* @param column A column number, from 0 to 7.
* @return An integer that describes the contents of the space.
*/
public int getSpaceContents (int row, int column);

/**
* Returns true if the board has four red checkers together in a row,
* column, or diagonal line. This would indicate a win for red.
*
* @return True if there are four red checkers in a line.
*/
public boolean redHasWon ();

/**
* Returns true if the board has four black checkers together in a row,
* column, or diagonal line. This would indicate a win for black.
*
* @return True if there are four black checkers in a line.
*/
public boolean blackHasWon ();

/**
* @return An integer that describes the winning color, if any.
*/
public int getWinner ();
}
xOx Frenchie xOx is offline   Reply With Quote
Reply

Bookmarks



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
i've set up remote play between my psp and ps3 which works fine when i connect pipper ripper Games 0 05-01-2008 06:41 PM
Change the value of a select box with Java Script? Jamaal E Web Programming 0 05-01-2008 01:30 PM
can anyone write the following in java language? geekguy Web Programming 1 05-01-2008 06:20 AM
I have a dell laptop w/webcam. I use Yahoo Messenger for IM but can't connect... jmia1912 Yahoo 0 04-30-2008 01:18 AM
JAVA help? swimmerxc Web Programming 0 04-28-2008 08:23 PM



All times are GMT +1. The time now is 11:41 AM.
Powered by vBulletin® Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Style Provided By: Wrestling Clique - Wrestling Forums

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44