This is what the program looks like


This is the code



import java.awt.*;
 
public class Scene extends java.applet.Applet
        {
        final int size = 30;
       	Animal animals[];
 
        public void init()
                {
		int i;
		animals = new Animal[size];
		for(i = 0; i < size; i++) {
			int x = 30 + 30 * i;
			int y = 100;
			int legs = i % 5;
			boolean eyes = false;
			if (i % 2 == 0) {
				eyes = true;
			}
			animals[i] = new Animal(x,y,legs, eyes);
                }
	}
 
        public void paint(Graphics g)
                {
		int i;
		for(i = 0; i < size; i++) {
			animals[i].paint(g);
                }
                
        }
}

class Animal {
	int x,y,legs;
	boolean eyes;
	Animal(int newx, int newy, int newlegs, boolean neweyes) {
		x = newx; y = newy; legs = newlegs; eyes = neweyes;
	}

	public void paint(Graphics g) {
		int i;
		// Draw the body
		g.drawRect(x,y,20,10);
		// Draw the eyes
		if (eyes) {
			g.fillOval(x+3, y+3, 2, 2);
		}
		// Draw the legs
		for(i = 0; i < legs; i++) {
			g.drawLine(x+3+i*3, y+10, x+3+i*3, y+15);
		}
	}
}