8. วัตถุสิ่งของ

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.

 
รหัสที่ 8-8  โปรแกรมแสดงลูกบอล แบบเรียกเมท็อดประจำอ็อบเจกต์
import jlab.graphics.DWindow;
public class TestBall {
  public static void main(String[] args) {
    DWindow w = new DWindow(200, 200);
    Ball[] balls = new Ball[300];
    for (int i=0; i<balls.length; i++)
      balls[i] = createRandomBall(200,200);
    w.setRepaintDuringSleep(true);
    while (true) {
      w.fade(0.3);
      for (int i=0; i<balls.length; i++) {
        balls[i].move(w);
        balls[i].draw(w);
      }
      w.sleep(50);
    }
  }
  ...
©2009 S.Prasitjutrakul