2. คำนวณ

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.

 
รหัสที่ 2-17  โปรแกรมลากเส้นที่ปรับปรุงจากรหัสที่ 2-16 ที่ใช้ตัวแปรเสริม
import jlab.graphics.DWindow;

public class LineDrawing {
  public static void main(String[] args) {
    double width = 200, height = 200, gap = 10;
    DWindow w = new DWindow(width, height);
    w.drawLine(width / 2, gap, width / 2, height - gap);
    w.drawLine(gap, height / 2, width - gap, height / 2);     
  }
}
©2009 S.Prasitjutrakul