// BugArrayPanel.java
// Dedicated drawing panel
import java.awt.*;
import javax.swing.*;

public class BugArrayPanel extends JPanel {
        RedBug red1 = new RedBug( "Laverne", 5, 400, 50, 50, 24, 8, 4, 10 );
        RedBug red2 = new RedBug( "Shirley", 6, 350, 130, 60, 30, 10, 6, 12 );
        GreenBug green1 = new GreenBug( "Kermit", 7, 300, 190, 20, 8, 4, 5 );
        GreenBug green2 = new GreenBug( "Gumby", 4, 200, 70, 16, 6, 3, 4 );
        BlueBug blue1 = new BlueBug( "Blue", 4, new Triangle( 70, 90, 40, 15 ), 8, 4 );
        BlueBug blue2 = new BlueBug( "Flix", 6, new Triangle( 420, 180, 80, 30 ), 12, 6 );

        Bug arrayOfBugs[ ] = { red1, red2, green1, green2, blue1, blue2 };  // superclass references

        public void paintComponent( Graphics g ) {
                super.paintComponent( g );
                int xPos = 60;
                int yPos = 220;
                
                for ( int i = 0; i < arrayOfBugs.length; i++ ) {
                        arrayOfBugs[ i ].crawl( );
                        arrayOfBugs[ i ].draw( g );
                        g.drawString( arrayOfBugs[ i ].toString( ), xPos, yPos );
                        yPos += 30;
                }
        }
}