📄 target.java
字号:
/*
* File: Target.java
* Name:
* Section Leader:
* -----------------
* This file is the starter file for the Target problem.
*/
import acm.graphics.*;
import acm.program.*;
import java.awt.*;
public class Target extends GraphicsProgram {
/**
*
*/
private static final long serialVersionUID = 1L;
private static final int BIG_RED_RADIUS = 72;
private static final int SMALL_RED_RADIUS = (int)(72 * 0.3);
private static final int WHITE_RADIUS = (int)(72 * 0.65);
public void run() {
int centerX = getWidth()/2;
int centerY = getHeight()/2;
/*big red circle*/
GOval big_red_circle = new GOval(centerX-BIG_RED_RADIUS, centerY-BIG_RED_RADIUS, 2 * BIG_RED_RADIUS, 2 * BIG_RED_RADIUS);
big_red_circle.setFillColor(Color.RED);
big_red_circle.setFilled(true);
add(big_red_circle);
/*white circle*/
GOval white_circle = new GOval(centerX-WHITE_RADIUS, centerY-WHITE_RADIUS, 2 * WHITE_RADIUS, 2 * WHITE_RADIUS);
white_circle.setFillColor(Color.WHITE);
white_circle.setFilled(true);
add(white_circle);
/*small red circle*/
GOval small_red_circle = new GOval(centerX-SMALL_RED_RADIUS, centerY-SMALL_RED_RADIUS, 2 * SMALL_RED_RADIUS, 2 * SMALL_RED_RADIUS);
small_red_circle.setFillColor(Color.RED);
add(small_red_circle);
small_red_circle.setFilled(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -