import java.util.*;
/**
 * Un Boton de una botonera
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Boton extends Observable implements Observer {
	private boolean pulsado;

	/**
	 * Constructor for objects of class Boton
	 */
	public Boton(boolean b) {
		// initialise instance variables
		pulsado = b;
	}

	/**
	 * An example of a method - replace this comment with your own
	 * 
	 * @param  y   a sample parameter for a method
	 * @return     the sum of x and y 
	 */
	public boolean estaPulsado() {
		// put your code here
		return pulsado;
	}
	public void liberar() {
		pulsado = false;
	}
	public void pulsar() {
		if (!estaPulsado()) {
			pulsado = true;
			setChanged();
			notifyObservers();
		}
	}
	public void update(Observable ob, Object o) {
		Boton b = (Boton)ob;
//		if (this!=b)
			liberar();
	}
	public String toString() {
		if (estaPulsado())
			return "#";
		else
			return "-";
	}
}
