A recursive “squid” is a square in a diamond containing another “squid”.

Your task is to implement the draw method of the squid. Draw the diamond, draw the square, then make another Squid with half the radius, and call its draw method. However, if the radius is too small, do nothing.

Viewer and component classes have been provided.

Complete the following file:


import java.awt.Graphics2D; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; public class Squid { /** Constructs a Squid (square inside diamond). @param aCenter the center point @param aRadius, the distance from the center to the corner points of the diamond */ public Squid(Point2D.Double aCenter, double aRadius) { center = aCenter; radius = aRadius; } public void draw(Graphics2D g2) { // your work here } private Point2D.Double center; private double radius; }

Use the following files:


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

public class SquidComponent extends JComponent
   public void paintComponent(Graphics g)
      Graphics2D g2 = (Graphics2D) g;
      Squid s = new Squid(new Point2D.Double(200, 200), 200);


import javax.swing.*;

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

      frame.setSize(450, 450);
      frame.setTitle("A recursive squid");

      SquidComponent component = new SquidComponent();