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

public class LED extends JLabel {

    // instance variables
    private int value;

    // class constant holding images of digits
    private static final Icon images[] = {
     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")
    };

   // LED(): default constructor 
   LED(int i) {
      setValue(i);
   }

   // getValue(): get the LED value
   public int getValue() {
      return value;
   }

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