Target solution updated

Added “setColor” to set the color of the borders. Thanks to my wife ,she notice that the borders need to be changed.

Screen Shot 2013-11-17 at 2.47.54 AM

target
target

Updated code

/*
 * 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 {
	
	public void run() {
		
		int center_x = getWidth() /2;
		int center_y = getHeight() /2;
		int out_radius = 72;
		int mid_radius = (int) (out_radius * 0.65);
		int inn_radius = (int) (out_radius * 0.3);
		
		// outer circle
		GOval out = new GOval(center_x-(out_radius/2),center_y-(out_radius/2),out_radius,out_radius);
		out.setFilled(true);
		out.setColor(Color.RED);
		out.setFillColor(Color.RED);
		add(out);
		
		//middle circle
		GOval mid = new GOval(center_x-(mid_radius/2),center_y-(mid_radius/2),mid_radius,mid_radius);
		mid.setFilled(true);
		mid.setColor(Color.WHITE);
		mid.setFillColor(Color.WHITE);
		add(mid);
		
		//inner circle
		GOval inn = new GOval(center_x-(inn_radius/2),center_y-(inn_radius/2),inn_radius,inn_radius);
		inn.setFilled(true);
		inn.setColor(Color.RED);
		inn.setFillColor(Color.RED);
		add(inn);
		
		
		}

	
}

/*
 * 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 {
	
	public void run() {
		
		int center_x = getWidth() /2;
		int center_y = getHeight() /2;
		int out_radius = 72;
		int mid_radius = (int) (out_radius * 0.65);
		int inn_radius = (int) (out_radius * 0.3);
		
		// outer circle
		GOval out = new GOval(center_x-(out_radius/2),center_y-(out_radius/2),out_radius,out_radius);
		out.setFilled(true);
		out.setFillColor(Color.RED);
		add(out);
		
		//middle circle
		// 
		GOval mid = new GOval(center_x-(mid_radius/2),center_y-(mid_radius/2),mid_radius,mid_radius);
		mid.setFilled(true);
		mid.setFillColor(Color.WHITE);
		add(mid);
		
		//inner circle
		GOval inn = new GOval(center_x-(inn_radius/2),center_y-(inn_radius/2),inn_radius,inn_radius);
		inn.setFilled(true);
		inn.setFillColor(Color.RED);
		add(inn);
		
		
		}

	
}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.