import java.io.*; /** * Used to start the program, and the man object handling * * @author Tyson Joehler and Aric Walker * @version 2/2/2005 */ public class Driver { public static void main (String [] args) throws IOException { // Gets the input for number of pegs UserInterface userInput = new UserInterface(); String name = userInput.getName(); boolean done = false; boolean done2 = false; int win = 0; int loss = 0; while (!done) { // done2 = false; int numPegs = userInput.getNumPegs(); int numColors = userInput.getNumColors(); // Makes the randomly ordered answer array Answer myAnswer = new Answer (numPegs, numColors); // Creates the new row, with a length of the number of pegs input Row myRow = new Row(numPegs); // Creates and records the answer into memory myAnswer.createAnswer(); myRow.setAnswer(myAnswer); Display myDisplay = new Display(numPegs, NUM_TRIES); System.out.println("************************************************************"); int count = 0; while (!done2) { // Creates a while loop to re-create the board. // Asks the user to guess Guess myGuess = new Guess(numPegs); // Records the guess into the memory myGuess.createGuess(); myRow.setGuess(myGuess); // Scores the guess myRow.scoreGuess(); // Set the array that holds the guesses and results myDisplay.setGuess(count, myGuess); myDisplay.setScore(myRow.getNumBlack(), myRow.getNumWhite(), count); myDisplay.print(); // Adds one to count count++; if (myRow.getNumBlack() == numPegs) { //adds one to the win count win++; done2 = true; boolean result = true; done = userInput.tryAgain(win, loss, result, myAnswer); } else if(count == NUM_TRIES) { done2 = true; //adds one to the loss count loss++; boolean result = false; done = userInput.tryAgain(win, loss, result, myAnswer); } else { done2 = false; } } // done2 end of loop // Clears the screen System.out.print('\u000C'); } // done end of loop } private static final int NUM_TRIES = 10; }