9. สร้างใหม่จากเก่า

The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

 
รหัสที่ 9-6  คลาส DecimalLED
import jlab.graphics.DWindow;
public class DecimalLED extends DotMatrixLED {
  private static final boolean[][] zero =
      { { false, true, true, true, false },
        { true, false, false, false, true },
        { true, false, false, false, true },
        { true, false, false, false, true },
        { true, false, false, false, true },
        { true, false, false, false, true },
        { false, true, true, true, false } };
  //
  // ... ขอละไม่แสดงรายละเอียดของเลข  one, two, ..., nine
  //
  private static final boolean[][][] dots =  
    { zero, one, two, three, four, five, six, seven, eight, nine };
  private int digit;

  public DecimalLED() {
    super(5,7);
    setDigit(0);
  }
  public void setDigit(int n) {
    if (n < 0 || n > 9) throw new IllegalArgumentException("" + n);
    digit = n;
    super.setDots(dots[digit]);
  }
  public int getDigit() {
    return digit;
  }
  public void setDots(boolean[][] s) {
    throw new UnsupportedOperationException();
  }
}
©2009 S.Prasitjutrakul