//URLTURT.java - produces an entire turtle (calls URLSHELL)
// by Randy McGirr Searles Valley 2011
import java.awt.*;
import java.util.*;

public class URLTURT{
  int x, y, color;
  URLSHELL shells[] = new URLSHELL[6];
  Random r;
//  Color colors[] = { Color.red, Color.yellow, Color.green, Color.cyan,
//    new Color(125,125,125), Color.magenta, new Color(99,50,255),
//    Color.orange, Color.pink };
  Color colors[] = { new Color(125,125,125), Color.orange, Color.green, new Color(99,50,255), Color.yellow };                                          

  URLTURT(int a, int b, int c){
    x=a;
    y=b;
    color=c;
    r=new Random();
    setShells();
  }
  
  public void setShells(){
    for(int i=0; i<shells.length; i++){
      shells[i]=new URLSHELL(x+15+i*6,y-i*13,22-i*2);
    }
  } 
  
  public void draw(Graphics g){
    //int pick=Math.abs(r.nextInt()%colors.length);
    //g.setColor(colors[pick]);
    g.setColor(colors[color]);
     //tail
    int c[] = {x+42,x+55,x+40,x+22,x+32,x+42 };
    int d[] = {291,291,296,300,296,291 };
    Polygon tail = new Polygon(c,d,c.length);
    g.fillPolygon(tail);
    //back leg
    int bx[]={x+67,x+77,x+87,x+57,x+67};
    int by[]={291,291,310,310,291};
    Polygon backleg=new Polygon(bx,by,bx.length);
    g.fillPolygon(backleg);    
    //front leg
    int fx[]={x+117,x+127,x+137,x+107,x+117};
    int fy[]={291,291,310,310,291};
    Polygon frontleg=new Polygon(fx,fy,fx.length);
    g.fillPolygon(frontleg);    
    //head
    int hx[]={x+140,x+165,x+175,x+190,x+200,x+190,x+175,x+165,x+150,x+140};
    int hy[]={291,291,270,270,291,305,305,300,300,291};
    Polygon head=new Polygon(hx,hy,hx.length);
    g.fillPolygon(head);    
    g.setColor(new Color(0, 0, 0));
    g.fillOval(x+186,280,5,5);
    g.drawLine(x+195,300,x+185,295);
    for(int i=0; i<shells.length; i++){
      shells[i].draw(g);
    }
  }
}
