FileDocCategorySizeDatePackage
Vocab.javaAPI DocApache Struts 2.0.9 Apps2916Mon Jul 23 13:43:26 BST 2007org.apache.struts2.showcase.hangman

Vocab

public class Vocab extends Object implements Serializable

Fields Summary
private static final long
serialVersionUID
private String
vocab
private String
hint
private Character[]
characters
Constructors Summary
public Vocab(String vocab, String hint)

 // character this vocab is made up of

         
        assert(vocab != null);
        assert(hint != null);

        this.vocab = vocab.toUpperCase();
        this.hint = hint;
    
Methods Summary
public java.lang.BooleancontainCharacter(java.lang.Character character)

        assert(character != null);

        return (vocab.contains(character.toString())) ? true : false;
    
public booleancontainsAllCharacter(java.util.List charactersGuessed)

        Character[] chars = inCharacters();
        List<Character> tmpChars = Arrays.asList(chars);
        return charactersGuessed.containsAll(tmpChars);
    
public java.lang.StringgetHint()

 return this.hint; 
public java.lang.StringgetVocab()

 return this.vocab; 
public java.lang.Character[]inCharacters()

        if (characters == null) {
            char[] c = vocab.toCharArray();
            characters = new Character[c.length];
            for (int a=0; a< c.length; a++) {
                characters[a] = Character.valueOf(c[a]);
            }
        }
        return characters;
    
public static voidmain(java.lang.String[] args)

        Vocab v = new Vocab("JAVA", "a java word");

        List<Character> list1= new ArrayList<Character>();
        list1.add(new Character('J"));
        list1.add(new Character('V"));

        List<Character> list2 = new ArrayList<Character>();
        list2.add(new Character('J"));
        list2.add(new Character('V"));
        list2.add(new Character('A"));

        System.out.println(v.containsAllCharacter(list1));
        System.out.println(v.containsAllCharacter(list2));