/*
 * Created on Nov 11, 2004
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package WheelOfFortune.game.userInput;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Icon;

import WheelOfFortune.game.GameModel;

/**
 * @author caih
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class LetterAction extends AbstractAction {

	private GameModel gm;
	private GameInput gi;
	/**
	 * @param arg0
	 */
	public LetterAction(String name, GameModel gm, GameInput gi) {
		putValue(Action.NAME, name);
		this.gm = gm;
		this.gi = gi;
		
		// TODO Auto-generated constructor stub
	}
	/**
	 * @param arg0
	 * @param arg1
	 */
	public LetterAction(String name, Icon ic, GameModel gm, GameInput gi) {
		this.gm = gm;
		this.gi = gi;
		putValue(Action.NAME, name);
		putValue(Action.SMALL_ICON, ic);
		// TODO Auto-generated constructor stub
	}

	public String getName(){
		return ((String)getValue(Action.NAME)).trim(); }
	
	public void actionPerformed(ActionEvent e){
		gi.disableActions();
		String s = ((String)getValue(Action.NAME)).trim();
		char c = s.charAt(0);
		String vowel = "AEIOU";
		for(int i = 0; i < vowel.length(); i++)
		{
			if(c == vowel.charAt(i))
				gm.guessVowel(c);
		}
		gm.guessConsonant(c);
		
	}

}
