Created
March 14, 2015 14:36
-
-
Save kenechiokolo/ba1c7ab50acf9d11d5b7 to your computer and use it in GitHub Desktop.
CS106A: Assignment 2.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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 { | |
int ppi = 72; | |
public void run() { | |
outerCircle(); | |
whiteCircle(); | |
bullseye(); | |
} | |
private void outerCircle() { | |
int x = getWidth() / 2; | |
int y = getHeight() / 2; | |
double r = ppi * 1; | |
GOval circle = new GOval (x-r, y-r, r*2, r*2); | |
circle.setFillColor(Color.red); | |
circle.setFilled(true); | |
circle.setColor(Color.red); | |
add (circle); | |
} | |
private void whiteCircle() { | |
int x = getWidth() / 2; | |
int y = getHeight() / 2; | |
double r = ppi * 0.65; | |
GOval circle = new GOval (x-r, y-r, r*2, r*2); | |
circle.setFilled(true); | |
circle.setColor(Color.white); | |
circle.setFillColor(Color.white); | |
add (circle); | |
} | |
private void bullseye() { | |
int x = getWidth() / 2; | |
int y = getHeight() / 2; | |
double r = ppi * 0.3; | |
GOval circle = new GOval (x-r, y-r, r*2, r*2); | |
circle.setFilled(true); | |
circle.setColor(Color.red); | |
circle.setFillColor(Color.red); | |
add (circle); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment