/** * Displays the users input guess and the result all the way through the game- * simulates the gameboard. * * @author Tyson Joehler and Aric Walker * @version 2/2/2005 */ public class Display { /** * Class constructor for display * * @param width The number of pegs wide the board is * @param height How tall the array is - NUM_TRIES */ Display(int width, int height) { this.height = height; displayArray = new int[width][height]; scoreArray = new int[2][height]; } /** * Sets the current guess into the display array * * @param guessNumber The position (height) that this guess goes into- count * @param guess The current guess */ public void setGuess(int guessNumber, Guess guess) { // int guessArray[] = new int [guess.getLength()]; for(int i = 0; i < guess.getLength(); i++) { guessArray[i] = guess.getGuess(i); displayArray[i][guessNumber] = guessArray[i]; } } /** * Sets the result if the guess * * @param black The number of black pegs this score * @param white The number of white pegs this score * @param guessNumber The position (height) that this score goes into- count */ public void setScore(int black, int white, int guessNumber) { int[] score = new int[2]; score[0] = black; score[1] = white; for (int i = 0; i < 2; i++) { scoreArray[i][guessNumber] = score[i]; } } /** * Prints out the array and the results */ public void print() { for(int j=0; j < height; j++) { for(int i=0; i < displayArray.length; i++) { System.out.print(displayArray[i][j]); } System.out.println(" Blacks: " + scoreArray[0][j] + " Whites: " + scoreArray[1][j]); } } private int[][] scoreArray; private int[][] displayArray; private int height; }