org.jscience.computing.game
Class JDefaultGame

java.lang.Object
  extended by org.jscience.computing.game.JDefaultGame
All Implemented Interfaces:
JGamePlay
Direct Known Subclasses:
JAwari, JBlackJack, JCheckers, JChess, JFourWins, JGomoku, JMuehle, JReversi, JSolitaire, JWS

public class JDefaultGame
extends java.lang.Object
implements JGamePlay

JDefaultGame provides a basic wrapper for GamePlay objects for implementing the JGamePlay interface. JDefaultGame enables any GamePlay to be played with a JGameFrame if the game has no specific requirements for its display (or you can extend this class to ease the implementation of the interface). JDefaultGame relies on proper toString() methods to be set for the game and its moves; it further requires that a default constructor with no arguments is accessible from this class. Also, the GamePlay and all its associated objects must be serializable for game saving/loading.

See Also:
JGameFrame, JGamePlay

Field Summary
protected  ExtensionFileFilter filter
          DOCUMENT ME!
protected  GameGUI frame
          DOCUMENT ME!
protected  AutoPlay play
          DOCUMENT ME!
 
Fields inherited from interface org.jscience.computing.game.JGamePlay
gameFrameX, gameFrameY, historyFrameX, historyFrameY, legalMovesFrameX, legalMovesFrameY, prototypeCellValue, redoFrameX, redoFrameY, windowHeight, windowLocationX, windowLocationY, windowWidth
 
Constructor Summary
JDefaultGame(GamePlay game)
          Creates a new JDefaultGame object.
JDefaultGame(GamePlay game, Player[] player, int level, ExtensionFileFilter filter)
          Creates a new JDefaultGame object.
 
Method Summary
 AutoPlay getAutoPlay()
          DOCUMENT ME!
 java.awt.Container getContainer(GameGUI frame)
          takes the toString() function of the GamePlay and turns it into formatted html, which is returned as a JLabel
 java.lang.String getDefaultFileExtension()
          DOCUMENT ME!
 javax.swing.filechooser.FileFilter getFileFilter()
          DOCUMENT ME!
 java.awt.Container getHelp()
          returns null if not overwritten
 javax.swing.JMenu getMenu()
          returns null if not overwritten
 JGamePlay getNewGame()
          depends on a default constructor being accessible for the GamePlay object in question
 java.lang.String getStatusMessage()
          indicates the number of moves performed, number of legal moves available, and indicates if someone won the game.
 java.lang.String getTitle()
          returns getGameName() from the GamePlay object
protected  void setFileFilter(ExtensionFileFilter filter)
          DOCUMENT ME!
 JGamePlay setGame(AutoPlay play)
          DOCUMENT ME!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

frame

protected GameGUI frame
DOCUMENT ME!


play

protected AutoPlay play
DOCUMENT ME!


filter

protected ExtensionFileFilter filter
DOCUMENT ME!

Constructor Detail

JDefaultGame

public JDefaultGame(GamePlay game)
Creates a new JDefaultGame object.

Parameters:
game - DOCUMENT ME!

JDefaultGame

public JDefaultGame(GamePlay game,
                    Player[] player,
                    int level,
                    ExtensionFileFilter filter)
Creates a new JDefaultGame object.

Parameters:
game - DOCUMENT ME!
player - DOCUMENT ME!
level - DOCUMENT ME!
filter - DOCUMENT ME!
Method Detail

getContainer

public java.awt.Container getContainer(GameGUI frame)
takes the toString() function of the GamePlay and turns it into formatted html, which is returned as a JLabel

Specified by:
getContainer in interface JGamePlay
Parameters:
frame - DOCUMENT ME!
Returns:
DOCUMENT ME!

getAutoPlay

public AutoPlay getAutoPlay()
DOCUMENT ME!

Specified by:
getAutoPlay in interface JGamePlay
Returns:
DOCUMENT ME!

getFileFilter

public javax.swing.filechooser.FileFilter getFileFilter()
DOCUMENT ME!

Specified by:
getFileFilter in interface JGamePlay
Returns:
DOCUMENT ME!

setFileFilter

protected void setFileFilter(ExtensionFileFilter filter)
DOCUMENT ME!

Parameters:
filter - DOCUMENT ME!

getDefaultFileExtension

public java.lang.String getDefaultFileExtension()
DOCUMENT ME!

Specified by:
getDefaultFileExtension in interface JGamePlay
Returns:
DOCUMENT ME!

getMenu

public javax.swing.JMenu getMenu()
returns null if not overwritten

Specified by:
getMenu in interface JGamePlay
Returns:
DOCUMENT ME!

getNewGame

public JGamePlay getNewGame()
depends on a default constructor being accessible for the GamePlay object in question

Specified by:
getNewGame in interface JGamePlay
Returns:
DOCUMENT ME!
Throws:
java.lang.RuntimeException - DOCUMENT ME!

setGame

public JGamePlay setGame(AutoPlay play)
                  throws GameRuntimeException
DOCUMENT ME!

Specified by:
setGame in interface JGamePlay
Parameters:
play - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
GameRuntimeException - DOCUMENT ME!

getTitle

public java.lang.String getTitle()
returns getGameName() from the GamePlay object

Specified by:
getTitle in interface JGamePlay
Returns:
DOCUMENT ME!
See Also:
GamePlay.getGameName()

getStatusMessage

public java.lang.String getStatusMessage()
indicates the number of moves performed, number of legal moves available, and indicates if someone won the game.

Specified by:
getStatusMessage in interface JGamePlay
Returns:
DOCUMENT ME!

getHelp

public java.awt.Container getHelp()
returns null if not overwritten

Specified by:
getHelp in interface JGamePlay
Returns:
DOCUMENT ME!