/** * This class extends our BasicGame to be cooler. * * @author Mr. Merlis * @version 3/16/2009 */ public class GuessWordGame extends BasicGame { private String[] hints = new String[5]; private int curGuessNum; private String[] words = {"firstWord", "secondW", "tW"}; private int curWordIndex; public GuessWordGame() { hints[0] = "This is hint 1"; hints[1] = "This is hint 2"; hints[2] = "Hint 3 baby"; hints[3] = "This hinto fouro"; hints[4] = "Fiveo!"; curGuessNum = 0; curWordIndex = 0; }//========================= public boolean shouldContinue() { if( ! words[curWordIndex].equals (itsUsersWord)) { curGuessNum++; // another wrong guess return true; } else // guessed the word correctly! { curGuessNum = 0; curWordIndex++; return false; } } //====================== public void showUpdatedStatus() { JOptionPane.showMessageDialog (null, "That was wrong. Hint: " + hints[(curGuessNum-1)%hints.length]); } //====================== }