package visiteur;

import java.util.HashMap;

@Exercice(2)
public class Variable extends AbstractExpression {
	private char value;
	private static HashMap<Character, Variable> variables=new HashMap<Character, Variable>();
	
	private Variable(char v){
		value=v;
	}

	@Exercice(6)
	public static Variable getInstance(char v){
		Variable var = variables.get(v);
		if( var == null){
			var= new Variable(v);
			variables.put(v, var);
		}
		return var;
	}
	
	/* Supprimé dans l'exo 7
	@Override
	public void accept(Visitor v) {
		v.visit(this);
	}
	*/

	public char getValue() {
		return value;
	}
	
}
