Skip to content

Instantly share code, notes, and snippets.

@kenechiokolo
Created March 14, 2015 14:36
Show Gist options
  • Save kenechiokolo/ba1c7ab50acf9d11d5b7 to your computer and use it in GitHub Desktop.
Save kenechiokolo/ba1c7ab50acf9d11d5b7 to your computer and use it in GitHub Desktop.
CS106A: Assignment 2.2
/*
* 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