Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package samples;
- import acm.graphics.GCompound;
- import acm.graphics.GOval;
- public class GFace extends GCompound {
- private final int FACE_HEIGHT = 200;
- private final int FACE_WIDTH = 150;
- private final int EYE_RADIUS = 25;
- private final int EYE_OFFSET_X = 10;
- private final int EYE_OFFSET_Y = 40;
- public GFace() {
- // Face
- GOval oval = new GOval(FACE_WIDTH, FACE_HEIGHT);
- this.add(oval);
- // Eye1
- GOval eye1 = new GOval(2 * EYE_RADIUS, 2 * EYE_RADIUS);
- int x1 = FACE_WIDTH / 2 - EYE_OFFSET_X - 2 * EYE_RADIUS;
- this.add(eye1, x1, EYE_OFFSET_Y);
- // Eye2
- GOval eye2 = new GOval(2 * EYE_RADIUS, 2 * EYE_RADIUS);
- int x2 = FACE_WIDTH / 2 + EYE_OFFSET_X;
- this.add(eye2, x2, EYE_OFFSET_Y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement