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-20  คลาส Ball3DColor วาดลูกบอลเป็นวงกลมมีสี
import jlab.graphics.*;

public class Ball3DColor extends Ball3D {
  private int color;
  public Ball3DColor(int c, double r, double x, double y,double z){
    super(r, x, y, z);
    color = c;
  }
  public void draw(DWindow3D w3) {
    drawShadow(w3);
    w3.fillEllipse(color, x, y, z, 2*r, 2*r);
  }
  private void drawShadow(DWindow3D w3) {
    double s = y / w3.getHeight();
    w3.fillEllipse(DWindow.BLACK, x, w3.getHeight(), z,
                   2*r*s, r/2*s);
  }
}
©2009 S.Prasitjutrakul