// Class LED: simulates an LED for a clock or timer
import javax.swing.*;

public class LED extends JLabel {

    // instance variables
    private int myValue;
    // class constant holding images of digits
    private final static Icon myImages[] = {
     new ImageIcon("digit0.gif"),
     new ImageIcon("digit1.gif"),
     new ImageIcon("digit2.gif"),
     new ImageIcon("digit3.gif"),
     new ImageIcon("digit4.gif"),
     new ImageIcon("digit5.gif"),
     new ImageIcon("digit6.gif"),
     new ImageIcon("digit7.gif"),
     new ImageIcon("digit8.gif"),
     new ImageIcon("digit9.gif"),
     new ImageIcon("colon.gif"),
     new ImageIcon("leta.gif"),
     new ImageIcon("letm.gif"),
     new ImageIcon("letp.gif"),
     new ImageIcon("blank.gif")
    };

    public final static int COLON = 10;
    public final static int LETA  = 11;
    public final static int LETM  = 12;
    public final static int LETP  = 13;
    public final static int BLANK = 14;

   // LED(): default constructor 
   LED(int i) {
      myValue = i;
      setIcon(myImages[i]);
   }

   // getValue(): set the LED to a new value
   public int getValue() {
      return myValue;
   }

   // setValue(): set the LED to a new value
   public void setValue(int i)
    throws ArrayIndexOutOfBoundsException {
      myValue = i;
      setIcon(myImages[i]);
   }
}
