// RedBug.java
// User-defined class RedBug.java
// Subclass of Bug
// Shows dynamic method  binding and polymorphism
import java.awt.*;

public class RedBug extends Bug {
	private int x, y;  // x and y coordinates of body
	private int s;  // speed of crawl
	private int w, h;  // body width and height
	private int l, f, lg;  // leg and foot size and gap between legs

	public RedBug( String name, int speed, int xCoord, int yCoord, int width, int height, int leg, int foot, int legGap ) {
		super( name );
		s = speed;
		x = xCoord;
		y = yCoord;
		w = width;
		h = height;
		l = leg;
		f = foot;
		lg = legGap;
	}

	public void draw( Graphics g ) {
		g.setColor( Color.black );

		for ( int i = 1; i <= 4; i ++ ) {
			g.drawLine( x + i * lg - f, y - l, x + i * lg, y - l );  // top foot
			g.drawLine( x + i * lg, y - l, x + i * lg, y + h + l );  // long line
			g.drawLine( x + i * lg - f, y + h + l, x + i * lg, y + h + l );  // bottom foot
		}
		
		g.drawLine( x - 3, y + h / 2 - 7, x + 1, y + h / 2 - 2 );
		g.drawLine( x - 3, y + h / 2 + 7, x + 1, y + h / 2 + 2 );
		g.setColor( Color.green );
		g.fillOval( x - 4, y + h / 2 - 8, 3, 3 );
		g.fillOval( x - 4, y + h / 2 + 6, 3, 3 );

		g.setColor( Color.red );
		g.fillOval( x, y, w, h );
		g.setColor( Color.black );
		g.fillOval( x + 12, y + 12, 4, 4 );
		g.fillOval( x + 25, y + 5, 4, 4 );
		g.fillOval( x + 35, y + 15, 4, 4 );
	}

	public void crawl( ) {
		x -= s;
	}

	public String toString( ) {
		return "The lady is named:  " + getBugName( );
	}
}