1 import java.awt.*;
2 import java.awt.geom.*;
3
4 /**
5
6 */
7 public class HouseShape extends CompoundShape
8 {
9 /**
10
11 @param x
12 @param y
13 @param width
14 */
15 public HouseShape(int x, int y, int width)
16 {
17 Rectangle2D.Double base
18 = new Rectangle2D.Double(x, y + width, width, width);
19
20 //
21 Point2D.Double r1
22 = new Point2D.Double(x, y + width);
23 //
24 Point2D.Double r2
25 = new Point2D.Double(x + width / 2, y);
26 //
27 Point2D.Double r3
28 = new Point2D.Double(x + width, y + width);
29
30 Line2D.Double roofLeft
31 = new Line2D.Double(r1, r2);
32 Line2D.Double roofRight
33 = new Line2D.Double(r2, r3);
34
35 add(base);
36 add(roofLeft);
37 add(roofRight);
38 }
39 }