Mancala is a family of board games played around the world s
Mancala is a family of board games played around the world, sometimes called \"sowing\" games, or \"count-and-capture\" games, which describes the gameplay. The Kalah variant was imported to the United States in 1940. This game favors the starting player, who will always win the three-seed to six-seed versions with perfect play. As a result, this variant is usually considered a children\'s game. mancalaBoard Rules The game provides a Kalah board and a number of seeds or counters. The board has 12 small pits, called houses, on each side; and a big pit, called an end zone, at each end. The object of the game is to capture more seeds than one\'s opponent. At the beginning of the game, four seeds are placed in each house. This is the traditional method. Each player controls the six houses and their seeds on the player\'s side of the board. The player\'s score is the number of seeds in the store to their right. Players take turns sowing their seeds. On a turn, the player removes all seeds from one of the houses under their control. Moving counter-clockwise, the player drops one seed in each house in turn, including the player\'s own store but not their opponent\'s. If the last sown seed lands in an empty house owned by the player, and the opposite house contains seeds, both the last seed and the opposite seeds are captured and placed into the player\'s store. If the last sown seed lands in the player\'s store, the player gets an additional move. There is no limit on the number of moves a player can make in their turn. When one player no longer has any seeds in any of their houses, the game ends. The other player moves all remaining seeds to their store, and the player with the most seeds in their store wins. It is possible for the game to end in a draw. Requirements The project name shall be _GEM_Mancala Create a JSP-based application using MVC architecture that implements the Mancala game as described above The application must display: The game board current player indicator current number of seeds in each pit current scores (number of seeds in each house) game over indicator winner indicator a quit button The game cannot use old-style scriptlet tags (<% %>), expression tags (<%= %>) or declaration tags (<%! %>) mancalaStamp
Solution
_GEM_Mancala
public interface Board {
String board();
}
class Classic implements Board{
@Override
public String board() {
return \"Classic\";
}
}
class Zelda implements Board{
@Override
public String board() {
return \"Zelda\";
}
}
MancalaBoard.java
public class MancalaBoard extends JComponent {
private static final int DEFAULT_WIDTH = Toolkit.getDefaultToolkit().getScreenSize().width; //sets the width to the users screen dimension
private static final int DEFAULT_HEIGHT = Toolkit.getDefaultToolkit().getScreenSize().height; //sets the height to the users screen dimension
private static final int BOARD_WIDTH = DEFAULT_WIDTH - 100;
private static final int BOARD_HEIGHT = DEFAULT_HEIGHT - 100;
private static int pits;
private int stones;
public Board boardType;
private JButton undoButton;
public MancalaBoard(int stones){
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
JFrame frame = new JFrame(\"Mancala Game\");
frame.setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//frame.setLocation((screen.width - 500) / 2, (screen.height - 300) / 2);
frame.setVisible(true);
pits = 14;
this.stones = stones; // user specified amount, no greater than 4
}
public String selectBoard(){
return boardType.board();
}
public void setBoardType(Board newBoardType){
boardType = newBoardType;
}
}
ClassicBoard.java
public class ClassicBoard extends MancalaBoard {
public ClassicBoard(){
super(4);
boardType = new Classic();
}
public Double boardShape(){
return new Rectangle2D.Double();
}
ZeldaBoard.java (yep,I\'m nerdy)
public class ZeldaBoard extends MancalaBoard {
public ZeldaBoard(){
super(4);
boardType = new Zelda();
}
//board shape will be an ellipse
}
MancalaTester.java
public class MancalaTester {
public static void main(String[] args) {
// TODO Auto-generated method stub
MancalaBoard myMancala = new MancalaBoard(4);
myMancala.setBoardType(new Classic());
System.out.println(\"myMancala: \" + myMancala.selectBoard());
}
}


