Write a program that draws a picture of a house. It could be as simple as the accompanying figure, or if you like, make it more elaborate (3-D, skyscraper, marble columns in the entryway, whatever). Implement a class House and supply a method draw(Graphics2D g2) that draws the house. Here is a sample program output:


Complete the following file:


import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.geom.Line2D; /** This class draws a house by allowing the user to specify houses of different sizes. */ public class House { ... /** Constructor to initiate the bottom left corner @param x the left corner coordinate @param y the bottom corner coordinate */ public House(int x, int y) { ... } /** Draws the house @param g2 the graphics context */ public void draw(Graphics2D g2) { ... } }

Use the following files:


import javax.swing.JComponent;
import java.awt.Graphics;
import java.awt.Graphics2D;

   Draws a picture of a house, using the House class.
public class HouseComponent extends JComponent
   public void paintComponent(Graphics g)
      Graphics2D g2 = (Graphics2D) g;

      int x = 100;
      int y = 200;

      House house = new House(x, y);



import javax.swing.*;

   Displays a frame that shows a house.
public class HouseViewer
   public static void main(String[] args)
      JFrame frame = new JFrame();

      frame.setSize(300, 500);
      frame.setTitle("A house");

      HouseComponent component = new HouseComponent();