Endodoi.java - This program mimiks a game of [email protected]

This preview shows page 1 - 3 out of 7 pages.

/**. * This program mimiks a game of Mancala * @author Andrew Peloquin * @version 1.0 **/ public class Endodoi { /**. * * @param pitsPerRow argument * @param numSeeds argument * @return newPits */ public static int[][] createNewPits(int pitsPerRow, int numSeeds) { int[][] newPits = new int[2][pitsPerRow]; int i; int j; for (i = 0; i < 2; i++) { for (j = 0; j < pitsPerRow; j++) { newPits[i][j] = numSeeds; } } return newPits; } /**. * * @param playerPits argument * @return labels */ public static char[][] playerPitLabels(int[][] playerPits) { int i; int j; int letter = 97; char label; char[][] labels = new char[2][playerPits[1].length]; for (i = 0; i < 2; i++) { for (j = 0; j < playerPits[1].length; j++) { label = (char) letter; labels[i][j] = label; letter++; } } return labels; } /**. * * @param gamePits argument * @param storePlayer1 argument * @param storePlayer2 argument * @param selectedPit argument * @param indicatePlayerTurn argument * @return finalPicture */ public static String drawBoard(int[][] gamePits, int storePlayer1, int storePlayer2, char selectedPit, int indicatePlayerTurn) { int i; int seed; int letterLabel = 97; char pitLabel;
int counter = 0; boolean showPlayer1 = true; boolean showPlayer2 = true; if (storePlayer1 == 0) { showPlayer1 = false; } if (storePlayer2 == 0) { showPlayer2 = false; } String row1 = ""; String row2 = ""; String row3 = ""; String row4 = ""; String row5 = ""; String row6 = ""; String row7 = ""; String finalPicture = ""; if (storePlayer1 == 0) { ++counter; } if (storePlayer2 == 0) { ++counter; } row1 = " +====++==++"; row4 = " +====++==++"; row7 = " +====++==++"; if (indicatePlayerTurn == 1) { if (showPlayer1) { if (storePlayer1 > 9) { row2 = 1 + "|(" + storePlayer1 + ")||\\/||"; } else { row2 = 1 + "|( " + storePlayer1 + ")||\\/||"; } } else { if (storePlayer1 > 9) { row2 = 1 + "|( )||\\/||"; } else { row2 = 1 + "|( )||\\/||"; } } row3 = " | st ||/\\||"; if (showPlayer2) {

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture