import sraja.lib.java.*; public class Main { private MindReader mr; private static final int MAX = 25; // ************************* // Main // ************************* public Main() { mr = new MindReader(); } // ************************* // play // ************************* public void play () { char guess, prediction; int right = 0, wrong = 0; do { Stdio.println(); Stdio.println ("Guess head or tails and i'll predict your guess."); // 1. make a prediction prediction = mr.getPrediction(); // 2. retrieve a guess from the user guess = Stdio.readChar ("What is your guess [h/t] ? "); // 3. check if (guess == prediction) { Stdio.println ("Yes!. I too predicted " + prediction); right++; } else { Stdio.println ("No. I predicted " + prediction); wrong++; } // 4. store the guess mr.storePlayerGuess(guess); Stdio.println ("Score = " + right + " | " + wrong); } while ((right < MAX) && (wrong < MAX)); // print the final outcome Stdio.println(); Stdio.println("Final tally = " + right + " | " + wrong); Stdio.println ((right > wrong) ? "I out guessed you" : "You beat me :-("); } // ************************* // main // ************************* public static void main (String[] args) { Main mn = new Main(); Stdio.println (" Welcome to MindReader"); do { mn.play(); } while (Stdio.readChar("\nPlay again [y/n] ? ") == 'y'); } }