📄 framedball.java
字号:
import objectdraw.*;import java.awt.Color;// A simple, round oval will a black border and a filled interior.public class FramedBall { // the interior of the ball private FilledOval body; // the black frame around the ball private FramedOval border; // Create the Framed and Filled ovals to make a ball with a border public FramedBall( double left, double top, double size, DrawingCanvas aCanvas) { body = new FilledOval(left, top, size, size, aCanvas); border = new FramedOval(left, top, size, size, aCanvas); } // move the ball by specified offsets public void move(double dx, double dy) { body.move(dx, dy); border.move(dx, dy); } // set the color of the interior of the ball public void setColor(Color hue) { body.setColor(hue); } // get the x coordinate of the corner of the ball public double getX() { return body.getX(); } // get the y coordinate of the corner of the ball public double getY() { return body.getY(); } // check to see if the ball contains a specified location public boolean contains(Location point) { return body.contains(point); } // move the ball to a specified position public void moveTo(double x, double y) { // move the ball by offsets needed to reach desired location this.move(x - body.getX(), y - body.getY()); } // move the ball to a specified position public void moveTo(Location point) { this.moveTo(point.getX(), point.getY()); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -