GMovingBall
Retired DISLab
import acm.graphics.*; public class GMovingBall extends GBall { /** Creates a new ball with radius r centered at the origin * @param w Weight of this ball (radius) * @param vecX x 축 방향의 벡터 크기 * @param vecY y 축 방향의 벡터 크기 */ public GMovingBall(double weight, GDimension vec) { super(weight); vector = new GDimension(vec); } /** Creates a new ball with radius r centered at (x, y) */ public GMovingBall(double weight, GDimension vec, double x, double y) { this(weight, vec); setLocation(x, y); } public GDimension getVector() { return new GDimension(vector); } public double getVectorX() { return vector.getWidth(); } public double getVectorY() { return vector.getHeight(); } public void setVector(GDimension vector) { this.vector = vector; } public void setVector(double dx, double dy) { vector.setSize(dx, dy); } private GDimension vector; // vector(dx, dy) }