/* Drawing Simple Shapes - Nancy McCracken */ import java.awt.*; public class Mushroom extends java.applet.Applet { public void paint(Graphics g) { setBackground(Color.white); // x and y origins of mushroom int ox = 20; int oy = 100; g.setColor(Color.yellow); g.fillRect (ox+30, oy+40, 20, 40); // drawArc (x, y, width, height, startangle, arcangle); g.fillArc (ox, oy, 80, 80, 180, -180); ox = 120; oy = 20; g.setColor (Color.green); // arrays for x and y points of the polygon int xpoints[] = {40, 40, 0, 20, 10, 30, 20, 50, 80, 70, 90, 80, 100, 60, 60}; int ypoints[] = {160,120,120,80, 80, 40, 40, 0, 40, 40, 80, 80, 120,120, 160}; for (int i = 0; i < xpoints.length; i++) { xpoints[i] += ox; ypoints[i] += oy; } g.fillPolygon(xpoints, ypoints, 15); g.setColor (Color.black); g.drawString("Mushroom and Tree", 60, 220); } }