All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class taxman.Game

java.lang.Object
   |
   +----taxman.Game

public class Game
extends Object
This is the control class for the game. It has no UI logic and it's only job is to send events to the various panels interested in the game progress.


Variable Index

 o CPU_CHOSE
 o CPU_MOVE
 o DEF_CPU_FIRST
 o DEF_LOOK_AHEAD
 o DEF_NUMS_USED
 o DEF_RANDOM
 o DEF_SOUND_STATE
 o DEF_USE_CUTOFF
 o GAME_OVER
 o HUMAN_CHOSE
 o HUMAN_MOVE
 o NEW_GAME
 o OPTIONS_CLOSE
 o OPTIONS_OPEN
 o SOUND_OFF
 o SOUND_ON

Constructor Index

 o Game()
Constructor does nothing.

Method Index

 o addPanel(GameUpdate)
Adds a panel to be updated when the game state changes
 o changeOptionsScreen(boolean)
A method to update panels when the options button is pressed.
 o makeCPUMove(int)
Makes a move for the CPU and alternates control to the human
 o newGame(boolean)
Control function to start a new game.
 o numberChosen(int)
A panel can report that a number is chosen (by a human)
 o optionsChanged(boolean, int, int, boolean, boolean)
Called by the option setting panel, this function changes game options.

Variables

 o HUMAN_MOVE
 public static final int HUMAN_MOVE
 o CPU_MOVE
 public static final int CPU_MOVE
 o HUMAN_CHOSE
 public static final int HUMAN_CHOSE
 o CPU_CHOSE
 public static final int CPU_CHOSE
 o NEW_GAME
 public static final int NEW_GAME
 o GAME_OVER
 public static final int GAME_OVER
 o OPTIONS_OPEN
 public static final int OPTIONS_OPEN
 o OPTIONS_CLOSE
 public static final int OPTIONS_CLOSE
 o SOUND_ON
 public static final int SOUND_ON
 o SOUND_OFF
 public static final int SOUND_OFF
 o DEF_NUMS_USED
 public static final int DEF_NUMS_USED
 o DEF_RANDOM
 public static final boolean DEF_RANDOM
 o DEF_CPU_FIRST
 public static final boolean DEF_CPU_FIRST
 o DEF_LOOK_AHEAD
 public static final int DEF_LOOK_AHEAD
 o DEF_USE_CUTOFF
 public static final boolean DEF_USE_CUTOFF
 o DEF_SOUND_STATE
 public static final boolean DEF_SOUND_STATE

Constructors

 o Game
 public Game()
Constructor does nothing.

Methods

 o newGame
 public synchronized void newGame(boolean first)
Control function to start a new game.

Parameters:
first - true if the human should go first. false if the CPU goes first
 o numberChosen
 public synchronized void numberChosen(int n)
A panel can report that a number is chosen (by a human)

Parameters:
n - the number that was chosen
 o optionsChanged
 public synchronized void optionsChanged(boolean a_b,
                                         int max_levels,
                                         int quantity,
                                         boolean random,
                                         boolean sound)
Called by the option setting panel, this function changes game options. Changing options will require a new game so the panel listing options should be de-activated during game play.

Parameters:
a_b - flag indicating whether alpha/beta pruning should be used (default = true)
max_levels - number of look-ahead levels for the CPU to search
quantity - the quantity of numbers to put in the game
random - whether or not to use random numbers (otherwise they are sequential
sound - True if the sound is turned on
 o changeOptionsScreen
 public synchronized void changeOptionsScreen(boolean optionsOpening)
A method to update panels when the options button is pressed.

Parameters:
optionsOpening - true if the options dialog is opening, false if it is closing
 o makeCPUMove
 public synchronized void makeCPUMove(int n)
Makes a move for the CPU and alternates control to the human

Parameters:
n - The number the CPU chose (in a different thread)
 o addPanel
 public void addPanel(GameUpdate panel)
Adds a panel to be updated when the game state changes

Parameters:
panel - The panel (using the interface - GameUpdate) that wants to know when the game state changes.

All Packages  Class Hierarchy  This Package  Previous  Next  Index