Skip to content

Instantly share code, notes, and snippets.

@NatashaTheRobot
Created October 31, 2011 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save NatashaTheRobot/1328631 to your computer and use it in GitHub Desktop.
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
/*
* 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);
}
}
@Abdul7869
Copy link

I am taking cs101 at staford. Need Need help with coding "image expressions excercises" -week 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment