import java.awt.*;
import javax.swing.*;

public class DrawShapes3 extends JApplet
{
   private Drawable[] shapes;

   public void init()
   {
     shapes = new Drawable[4];                    // array of 4 shapes
     shapes[0] = new Circ2(10, 20, 5);            // creating 2 circles
     shapes[1] = new Circ2(30, 20, 5);

     shapes[2] = new Rect2(0, 10, 50, 10);        // creating 2 rectangles
     shapes[3] = new Rect2(10, 0, 30, 10);
     setBackground(Color.yellow);
   }

   public void paint(Graphics g)
   {
     for (int i=0; i<shapes.length; i++)          // loop over all shapes
       shapes[i].draw(g);

     for (int i=0; i<shapes.length; i++)          // drawing another car
     { 
       shapes[i].moveTo(100, 150);
       shapes[i].draw(g);
     }
   }
}
