Created
October 31, 2011 19:41
-
-
Save NatashaTheRobot/1328631 to your computer and use it in GitHub Desktop.
This is the solution to the Target problem from Assignment 2 of the Stanford CS106A Introduction to Programming Methodology Class
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 { | |
public void run() { | |
putOuterCircle(); | |
putMiddleCircle(); | |
putInnerCircle(); | |
} | |
private void putOuterCircle() { | |
int radius = 72; | |
int x = getWidth()/2 - radius/2; | |
int y = getHeight()/2 - radius/2; | |
GOval OuterCircle = new GOval (x, y, radius, radius); | |
OuterCircle.setColor(Color.RED); | |
OuterCircle.setFilled(true); | |
OuterCircle.setFillColor(Color.RED); | |
add(OuterCircle); | |
} | |
private void putMiddleCircle() { | |
double radius = 72*64/100; | |
double x = getWidth()/2 - radius/2; | |
double y = getHeight()/2 - radius/2; | |
GOval MiddleCircle = new GOval (x, y, radius, radius); | |
MiddleCircle.setColor(Color.WHITE); | |
MiddleCircle.setFilled(true); | |
MiddleCircle.setFillColor(Color.WHITE); | |
add(MiddleCircle); | |
} | |
private void putInnerCircle() { | |
double radius = 72*3/10; | |
double x = getWidth()/2 - radius/2; | |
double y = getHeight()/2 - radius/2; | |
GOval InnerCircle = new GOval (x, y, radius, radius); | |
InnerCircle.setColor(Color.RED); | |
InnerCircle.setFilled(true); | |
InnerCircle.setFillColor(Color.RED); | |
add(InnerCircle); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am taking cs101 at staford. Need Need help with coding "image expressions excercises" -week 3