⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 target.java

📁 斯坦福大学的Java课上的作业
💻 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 + -