GBall.java

Retired DISLab
Swpark (토론 | 기여) 사용자의 2014년 1월 26일 (일) 09:43 버전
(비교) ← 이전 판 | 현재 판 (비교) | 다음 판 → (비교)
이동: 둘러보기, 찾기
/*
 * File: GBall.java
 * ----------------
 * This file defines a GObject class that represents a ball.
 */
import acm.graphics.*;
 
/**
 * This class defines a GCompound subclass that represents a ball
 * whose reference point is the center rather than the upper
 * left corner.
 */
public class GBall extends GCompound {
 
/** Creates a new ball with radius r centered at the origin */
    public GBall(double r) {
        radius = r;
        ball = new GOval(2 * radius, 2 * radius);
        ball.setFilled(true);
        add(ball, -radius, -radius);
 
        markAsComplete();
    }
 
    /** Creates a new ball with radius r centered at (x, y) */
    public GBall(double r, double x, double y) {
        this(r);
        setLocation(x, y);
    }
 
    public void setRadius(double r) {
        ball.setSize(r * 2, r * 2);
    }
 
    public double getRadius() {
        return radius;
    }
 
    /*
    public void setSize(double r) {
        ball.setSize(r, r);
    }
 
    public double getWidth() {
        return ball.getWidth();
    }
 
    public double getHeight() {
        return ball.getHeight();
    }
    */
 
    private GOval ball;
    private double radius;
}
개인 도구
이름공간
변수
행위
둘러보기
구성원
연구
연구실
기타
도구모음
인쇄/내보내기