Public feed #381280

Mine

public text v1 · immutable
Raw Edit
·published 2007-03-04 19:25 UTC
rendered paste body
/*
 * Game.java
 *
 * Created on January 29, 2007, 2:52 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package Mancala;

/**
 * Main class for the Mancala game.  This class coordinates the other classes used in the Mancala game.
 * @author Sophie Quigley
 */
public class Game {
    
    // CLASS CONSTANTS
    /**
     * Number of players for the game
     */
    public static final int PLAYERS = 2;
    /**
     * Number of pits (exclusing kalahas) that each player has
     */
    public static final int PITSPERPLAYER=6;
    /**
     * Total number of pits (excluding kalahas) for all the players
     */
    public static final int PITS = PLAYERS*PITSPERPLAYER;
    
    // CLASS VARIABLES
    
    // INSTANCE VARIABLES
    /**
     * Swing user interface assoviated with this game
     */
    private MancalaUI ui;
    /**
     * Board associated with this game
     */
    private Board board;
    /**
     * Number of seeds distributed in each pit at the beginning of each new game
     */
    private int seedsperpit;
    
    // CLASS METHODS
    /** Creates a new instance of Game */
    public Game() {
        ui = new MancalaUI(); 
        board = new Board();
        ui.setGame(this);
        ui.setBoard(board);
        board.setGame(this);
        board.setUi(ui);
        ui.BdisableStart();
       }
   
    // INSTANCE METHODS
    /**
     * Starts the game
     * @param seedsperpit Number of seeds distributed in each pit at the beginning of the game
     */
    public void play(int seedsperpit) {
        this.seedsperpit = seedsperpit;      
        board.dealSeeds(seedsperpit);
        ui.setVisible(true);
    }
    
}