package hangmanModel; /** * Represents a word in the hangman game. * An AWord can be empty or non-empty. * When it is empty it contains nothing. * When it is non-empty, it contains a character and another AWord. * Each character in a non-empty AWord can be hidden or visible. * When hidden, its String representation is "_". * When visible, its String representation is that of the character itself. * @author D. X. Nguyen */ public abstract class AWord { /** * Matches an input character with all the characters in this AWord, and * returns whether there is a match in the word. * Side effect: Makes all matching characters visible. * @param c the character to be matched. * @return whether there is a match in the word. */ public abstract boolean matchAll(char c); /** * Helper method for match. Called by the non-empty parent AWord to help * match the remaining characters in the word, given a boolean flag marking * whether or not there is a match so far. * @param c the character to be matched. * @param b whether there is a match previously in the word. * @return whether there is a match in the word. */ protected abstract boolean helpMatchAll(char c, boolean b); /** * @return whether all characters of the word are visible. */ public abstract boolean isAllVisible(); }