The Artima Developer Community
Sponsored Link

Java Answers Forum
how to do this program

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
yi

Posts: 3
Nickname: ching
Registered: Aug, 2002

how to do this program Posted: Aug 19, 2002 7:41 PM
Reply to this message Reply
Advertisement
Complete your design of the game Connect-4. Thus far, you have designed one class for the game (the Cell class). The Cell class encapsulates the cells that make up the board. You must now design a Board class and a GUI.

You must produce a design of the board component of the Connect-4 game as described in project 1. You will also need to design any exception classes required by the Board class. The Board is a container class and will provide an object that maintains a two-dimensional array of Cell objects. The container can be constructed knowing the number of columns and the number of rows for the desired board. However, the constructor should throw an IllegalBoardException if the requested number of columns and rows are either negative or too large. Functionality will be required for claiming a cell in a specified column of the board, for checking the board to determine if a specified cell is part of four connected cells and for the drawing of itself.
You must produce a design for a class named ConnectGUI that provides the view of the game. It will maintain two TextField objects so that the players can input the desired number of rows and columns for the board, a Button object to start the game after the row and column are entered, a Canvas object to display the colour of the current player, a TextField object to display messages as the game progresses and a Board object on which the game will be played. The class will implement the ActionListener class, which requires the design of actionPerformed method. This method will create a Board object of the desired dimensions when the start button is pressed. The class will also implement the MouseListener class, which will permit the players to indicate the cell of the board to be claimed. In particular, the mousePressed method will be designed so that the coordinates of the mouse will be selected and passed to the claim method of the Board object. The method will also keep track of the player whose turn it is, by re-setting the colour of the current player canvas on each successful claim. If a mouse event produces an unsuccessful claim, an appropriate message is displayed in the message field. The method also displays the results of the game when it logically finishes.

can someone help me do this one
this is my design

Class Board
Board(int length, int width);
Board(int size);
Board();
----------------------------------
private instance variables
Cell [][] gameBoard
boolean whosTurn
----------------------------------
public instance method
boolean isFull();
boolean addToken(int column)
boolean isWon();
int cell (int x, int y);
whosTurn()

Topic: applet Previous Topic   Next Topic Topic: what are the non pure java components in swing......

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use