import acm.graphics.*;
import java.awt.*;
import acm.program.*;
public class TargetProgram extends GraphicsProgram {
public void run() {
drawCircle1();
drawCircle2();
drawCircle3();
}
private void drawCircle1() {
GOval c1 = new GOval(240, 80, 215, 215);
c1.setFilled(true);
c1.setColor(Color.RED);
add(c1);
}
private void drawCircle2() {
GOval c2 = new GOval(273, 113, 150, 150);
c2.setFilled(true);
c2.setColor(Color.WHITE);
add(c2);
}
private void drawCircle3() {
GOval c3 = new GOval(310, 150, 75, 75);
c3.setFilled(true);
c3.setColor(Color.RED);
add(c3);
}
}
Here is the RobotProgram and my robot!
/* RobotProgram.java creates a robot face from the ACM package graphics */
import acm.graphics.*;
import acm.program.*;
import java.awt.*;
public class RobotProgram extends GraphicsProgram{
public void run() {
drawFace();
drawEyes();
drawNose();
drawMouth();
}
private void drawFace() {
GRect face = new GRect(220, 40, 250, 350);
face.setFilled(true);
face.setColor(Color.LIGHT_GRAY);
add(face);
}
private void drawEyes() {
GOval lEye = new GOval(260, 95, 50, 50);
GOval rEye = new GOval(380, 95, 50, 50);
lEye.setFilled(true);
lEye.setColor(Color.ORANGE);
rEye.setFilled(true);
rEye.setColor(Color.ORANGE);
add(lEye);
add(rEye);
}
private void drawNose() {
GRect nose = new GRect(335, 185, 20, 40);
nose.setFilled(true);
nose.setColor(Color.BLACK);
add(nose);
}
private void drawMouth() {
GRect mouth = new GRect(270, 280, 155, 50);
mouth.setFilled(true);
mouth.setColor(Color.WHITE);
add(mouth);
}
}
now on for some reading time to read chapter 3