public class CloneShapes2
{
  public static void main(String[] args) throws CloneNotSupportedException
  {
    Circ6 c = new Circ6(1, 2, 3);
    System.out.println("Original circle:");
    System.out.println(c);

    Circ6 c2 = c.clone();        // implementing tagging interface Cloneable
    System.out.println("\nCloned circle:");
    System.out.println(c2);
  }
}


class Circ6 extends Shape implements Cloneable
{
   private int radius;

   public Circ6(int xLoc, int yLoc, int radius)
   {
      super(xLoc, yLoc);
      this.radius = radius;
   }

   public int getRadius()
   {
      return radius;
   }

   public double getArea()
   {
      return Math.PI * radius * radius;
   }

   public void stretchBy(double factor)
   {
      radius = (int)Math.round(radius * factor);
   }

   public String toString()
   {
      String str = "CIRCLE \n"
                 + super.toString()
                 + "Radius: " + radius + "\n"
                 + "Area: " + getArea();
      return str;
   }

   public Circ6 clone() throws CloneNotSupportedException
   {
     Circ6 cloned = (Circ6) super.clone();  // making a deep copy
     cloned.radius = radius;
     return cloned;
   } 
}

