package cse1030; /** * Abstract base class for simple word puzzles such as scrambled * word puzzles (where the puzzle word is made up of the letters * of the original word in random order). This class provides * storage and access to the original word (the solution); subclasses are * responsible for providing storage and generation of the puzzle word. * * @author CSE1030Z * */ public abstract class AbstractWordPuzzle { /** * The solution to the puzzle. */ private String word; /** * Constructor to set the solution to the puzzle. * * @param word the solution to the puzzle */ protected AbstractWordPuzzle(String word) { this.word = word; } /** * Get the solution word. * * @return the solution word */ public String getWord() { return this.word; } /** * Get the puzzle. * * @return the puzzle word */ public abstract String getPuzzleWord(); /** * Get the string representation of the puzzle. The string is the * solution word, followed by " : " followed by the puzzle word. * * @see java.lang.Object#toString() * * @return the string representation of the puzzle */ public String toString() { return this.word + " : " + this.getPuzzleWord(); } }