Write a method randomShape that randomly generates objects implementing the Shape interface: some mixture of rectangles, ellipses, and lines, with random positions. Call it 10 times and draw all of them.

Here is a sample program output:

.

Complete the following file:

RandomShapeGenerator.java

Use the following files:

RandomShapeViewer.java

import javax.swing.*;

public class RandomShapeViewer
{
   public static void main(String[] args)
   {
      JFrame frame = new JFrame();

      final int FRAME_WIDTH = 300;
      final int FRAME_HEIGHT = 400;

      frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
      frame.setTitle("RandomShapeViewer");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      RandomShapesComponent component = new RandomShapesComponent();
      frame.add(component);

      frame.setVisible(true);
   }
}

RandomShapesComponent.java

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

public class RandomShapesComponent extends JComponent
{ 
   public void paintComponent(Graphics g) 
   {
      Graphics2D g2 = (Graphics2D) g;
      RandomShapeGenerator r = new RandomShapeGenerator(getWidth(), getHeight());

      for (int i = 1; i <= 10; i++)
         g2.draw(r.randomShape());
   }
}