import java.util.*;

public class HangmanEngine {
    private String[] wordList = {"accessible",
                                 "adaptation",
                                 "admixture",
                                 "agent",
                                 "albeit",
                                 "alias",
                                 "application",
                                 "arson",
                                 "assimilate",
                                 "athlete",
                                 "automorphic",
                                 "baccarat",
                                 "barnstorm",
                                 "bedraggle",
                                 "benevolent",
                                 "bigotry",
                                 "bluegrass",
                                 "blame",
                                 "bothersome",
                                 "brazilian",
                                 "bridge",
                                 "brunt",
                                 "bureaucratic",
                                 "bunch",
                                 "caliper",
                                 "cannonball",
                                 "caramel",
                                 "cashier",
                                 "cease",
                                 "ceremonial",
                                 "chateaux",
                                 "chin",
                                 "chosen",
                                 "cityscape",
                                 "clinician",
                                 "corner",
                                 "collapsible",
                                 "commonplace",
                                 "complimentary",
                                 "conflagration",
                                 "consort",
                                 "continued",
                                 "cotangent",
                                 "course",
                                 "creep",
                                 "crusade",
                                 "crude",
                                 "daisy",
                                 "daze",
                                 "decay",
                                 "degum",
                                 "depressor",
                                 "dew",
                                 "digestible",
                                 "divide",
                                 "downbeat",
                                 "dire",
                                 "eccentric",
                                 "embalm",
                                 "estranged",
                                 "excellent",
                                 "expel",
                                 "extent",
                                 "feign",
                                 "firewall",
                                 "flew",
                                 "flue",
                                 "forgiven",
                                 "frenchmen",
                                 "furnace",
                                 "gangplank",
                                 "glutinous",
                                 "grace",
                                 "greenery",
                                 "grommet",
                                 "guzzle",
                                 "handcuff",
                                 "happy",
                                 "headsman",
                                 "hemisphere",
                                 "hologram",
                                 "hydrophobic",
                                 "impeccable",
                                 "inalienable",
                                 "incommunicable",
                                 "indulgent",
                                 "influenza",
                                 "intelligible",
                                 "invertebrate",
                                 "jail",
                                 "jive",
                                 "joust",
                                 "kangaroo",
                                 "kick",
                                 "kettle",
                                 "lad",
                                 "laden",
                                 "light",
                                 "link",
                                 "lofty",
                                 "lovelace",
                                 "luminosity",
                                 "maestro",
                                 "mambo",
                                 "manual",
                                 "masonic",
                                 "meadow",
                                 "mercantile",
                                 "midwinter",
                                 "miscreant",
                                 "mommy",
                                 "muck",
                                 "mutant",
                                 "name",
                                 "narrate",
                                 "narrow",
                                 "nearby",
                                 "necklace",
                                 "neglect",
                                 "neither",
                                 "nouveau",
                                 "oboist",
                                 "octennial",
                                 "onrush",
                                 "osteopath",
                                 "palladian",
                                 "paramus",
                                 "parsonage",
                                 "payroll",
                                 "pentane",
                                 "perilous",
                                 "pickle",
                                 "pinch",
                                 "platonism",
                                 "poetic",
                                 "polygon",
                                 "posthumous",
                                 "predisposition",
                                 "progeny",
                                 "prostate",
                                 "prune",
                                 "purpose",
                                 "quarryman",
                                 "quit",
                                 "rev",
                                 "role",
                                 "samba",
                                 "sapling",
                                 "scrap",
                                 "seafood",
                                 "sen",
                                 "sevenfold",
                                 "shamefaced",
                                 "shopkeep",
                                 "sidewinder",
                                 "skyway",
                                 "smattering",
                                 "snip",
                                 "somewhat",
                                 "spade",
                                 "sped",
                                 "springy",
                                 "standpoint",
                                 "stead",
                                 "stroll",
                                 "subject",
                                 "sunflower",
                                 "suspension",
                                 "tachometer",
                                 "task",
                                 "technocrat",
                                 "terpsichorean",
                                 "thereon",
                                 "thoroughbred",
                                 "tonsillitis",
                                 "touch",
                                 "transpire",
                                 "trilobite",
                                 "troy",
                                 "tweak",
                                 "ugly",
                                 "under",
                                 "unify",
                                 "upstaird",
                                 "verbose",
                                 "vibrate",
                                 "vocal",
                                 "washbowl",
                                 "wept",
                                 "wolves",
                                 "wriggle",
                                 "yarn",
                                 "zombie",
                                 "zounds",
                                 "zucchini",
                                 "zygote"};

    private Random randomGenerator = new Random();
    private String answer;

    public void setWord() {
        int index = randomGenerator.nextInt(wordList.length);
        answer = wordList[index];
        System.out.println("Word is " + getAnswer());
    }

    public String getAnswer() {
        return answer;
    }

    public int getWordLength() {
        return answer.length();
    }

    public String show(String text, String guess) {
        char[] s = guess.toCharArray();
        char match = text.charAt(0);
        for (int i=0;i<getWordLength();i++) {
            if (answer.charAt(i) == match)
                s[i] = match;
        }
        //        String t = new String(s);
        return new String(s);
    }

    public boolean wordGuessed(String guess) {
        return guess.equals(answer);
    }

    public boolean checkGuess(String letter) {
        return answer.contains(letter);
    }
}
