

import java.awt.*;
import java.applet.*;
import java.applet.AudioClip;
import java.awt.FontMetrics;


public class ClassName extends Applet implements Runnable
{
    int fdc;
    AudioClip oopsClip;
    AudioClip magicClip;
    Graphics og;
    Font  f15, f18, f24, f42;
    FontMetrics fm;
    MediaTracker tracker;
    String DoneMessage;
    int mscore;
    boolean firstDraw = true;
    String scoreString;
    Color back;
    int timer;
    int imggone;
    int fscore;
    boolean gameover = false;
    int imgNum = 15;
    int buckNum = 3;
    int score;

    int cow;

    Image offscrImg;
    
    Image funFact;
    Image img[] = new Image[imgNum];
    dragable drag[] = new dragable[imgNum];
    bucket buck[] = new bucket[buckNum];
    Image buckimg[] = new Image[buckNum];
    Image cowimg[] = new Image[3];
    String endMessage[] = new String[4];
    String loadMessage[] = new String[5];
    String inoutMessage[] = new String[imgNum];
    String Instructions[] = new String[7];

    String FunMessage;
    bucket again;
    bucket nextRow;
    Image nextImage;
    bucket startBucket;
    Image startImage;
    Image startAgain;
    String s;
    Thread runme;
    boolean show = false;
    int px;
    int py;
    int pw;
    int ph;
    int mult;

    int qx;
    int qy;
    int qw;
    int qh;

    int rx;
    int ry;
    int rw;
    int rh;

    int sx;
    int sy;
    int loopcount;
    int a = 5;
    int b = 255;
    int c = 255;
    int d = 255;
    int e = 0;
    int f  = 0;
    int h, lmc;


    int selbuck;
    boolean cowoncan = false;
    boolean tempb = true;

  
    //Event dummy;
    
    public void start()
    {
       
           if(runme == null)
           {
            runme = new Thread(this);
            runme.start();
           }

    }

    public void stop()
    {
        if(runme != null)
        {
            runme.stop();
            runme = null;
        }

    }


    public void run()
    {


        while(!show)
        {

           try{
              runme.sleep(100);
           }catch(InterruptedException e){}

           if(tracker.checkID(0, true))
           {
              show = true;
              firstDraw = true;
           }
           repaint();

        }


    }


   
    public void reInit()
    {
       cowoncan = false;
       firstDraw = true;
       mscore = 10;
       imggone = 0;
       gameover = false;
       timer = 0;
       score = 0;
       cow = 0;
       scoreString = "";
       FunMessage = "";

       loopcount = 0;
       for(int buckCount = 0; buckCount < buckNum; buckCount++)
       {
           buck[buckCount].reset();
       }

       for(int imgCount = 0; imgCount < imgNum; imgCount++)
       {
          drag[imgCount].reset();
       }

       setNextRow();
       startBucket.x = -200;
       startBucket.y = -200;


    }

	public void init()
	{

	   f15 = new Font("Arial", Font.BOLD, 15);
	   f18 = new Font("Arial", Font.BOLD, 15);
	   f24 = new Font("Arial", Font.BOLD, 24);
	   f42 = new Font("Arial", Font.BOLD, 42);

	   fm = getFontMetrics(f18);

	   DoneMessage = "Click anywhere to continue!";
	   FunMessage = "";
       mscore = 10;
       scoreString = "";
       timer = 0;
       gameover = false;
       score = 0;
       cow = 0;

       show = false;
       imggone = 0;
       px = 100;
       py = 100;
       pw = 100;
       ph = 100;
       mult = 50;

       qx = 150;
       qy = 150;
       qw = 100;
       qh = 100;

       rx = 200;
       ry = 200;
       rw = 100;
       rh = 100;

       sx = 200;
       sy = 200;
       loopcount = 0;
       
          
       Instructions[0] = "Drag each item into the correct container "; 
       Instructions[1] = "('trash', 'recycling', or 'compost') and drop it."; 
     
       inoutMessage[0] = "Recycling an aluminum can saves energy to run a TV for 3 hours!";
       inoutMessage[1] = "Recycling Sunday papers could save about 500,000 trees a week!"; 
       inoutMessage[2] = "Juice pouches are made of various materials so recycling and composting is difficult.";
       inoutMessage[3] = "Recycled plastic is used to make benches, playground equipment and kayaks.";
       inoutMessage[4] = "$1 out of every $10 we spend on food pays for packaging!";
       inoutMessage[5] = "Bananas have their own biogdegradable packaging.";
       inoutMessage[6] = "A piece of styrofoam will NEVER decompose!";
       inoutMessage[7] = "40% of out garbage is made up of compostable kitchen and garden waste.";
       inoutMessage[8] = "The U.S. throws away more than 160 MILLION TONS of solid waste each year.";
       inoutMessage[9] = "A plastic cup can take 60 - 80 years to decompose!";
       inoutMessage[10] = "Bottles can be recycled into glass products, or even used in making pavement!";
       inoutMessage[11] = "Egg shells can be composted.";
       inoutMessage[12] = "Used napkins can be composted.";
       inoutMessage[13] = "Each person in the U.S. throws away about 4.4 pounds of waste every day!";
       inoutMessage[14] = "70% of our garbage is compostable, including wood, paper, yard and food waste. ";

       



       endMessage[0] = "What a waste! Try again. ";
       endMessage[1] = "A little sloppy! Try again for a better score";
       endMessage[2] = "Good score, recycle some of your answers and try again.";
       endMessage[3] = "Perfect score! You get a big wet pig kiss.";


       loadMessage[0] = "Recycling is the Coolest!";
       loadMessage[1] = "The recycling game is loading!";
       loadMessage[2] = "Don't go away it's coming!";
       loadMessage[3] = "This game is FUN!";;
       loadMessage[4] = "Trash sorting game coming up!";



	    tracker = new MediaTracker(this);

            oopsClip = getAudioClip(getDocumentBase(), "tgraphics/oops.wav");
            magicClip = getAudioClip(getDocumentBase(), "tgraphics/magic.wav");

            
	    back = new Color(200, 250, 100);
	    offscrImg = createImage(size().width, size().height);

	    again = new bucket(500, size().height-117, 117, 94);
	    startAgain = getImage(getDocumentBase(), "tgraphics/startagain.gif");
	    tracker.addImage(startAgain, 0);

	    funFact = getImage(getDocumentBase(), "graphics/funfact.gif");
	    tracker.addImage(funFact, 0);


	    startBucket = new bucket(400, 200, 72, 57);
	    startImage = getImage(getDocumentBase(), "graphics/start.gif");
	    tracker.addImage(startImage, 0);

	   	nextImage = getImage(getDocumentBase(), "graphics/next.gif");
	    tracker.addImage(nextImage, 0);
	    nextRow = new bucket(-100, -100, 72, 57);

	    cowimg[0] = getImage(getDocumentBase(), "graphics/coolcow.gif");
	    tracker.addImage(cowimg[0], 0);
	    cowimg[1] = getImage(getDocumentBase(), "tgraphics/yougotit.gif");
	    tracker.addImage(cowimg[1], 0);
	    cowimg[2] = getImage(getDocumentBase(), "tgraphics/oops.gif");
	    tracker.addImage(cowimg[2], 0);

	    buckimg[0] = getImage(getDocumentBase(), "tgraphics/trashcan2.gif");
	    tracker.addImage(buckimg[0], 0);
	    buckimg[1] = getImage(getDocumentBase(), "tgraphics/recyclingbin2.gif");
            tracker.addImage(buckimg[1], 0);
	    buckimg[2] = getImage(getDocumentBase(), "tgraphics/compost_bin.gif");
	    tracker.addImage(buckimg[2], 0);

	    buck[0] = new bucket(10, size().height-150, 100, 150);
	    buck[1] = new bucket(130, size().height-130, 159, 130);
	    buck[2] = new bucket(330, size().height-176, 150, 176);
	    
	    img[0] = getImage(getDocumentBase(), "tgraphics/aluminumcan.gif");
        tracker.addImage(img[0], 0);
        drag[0] = new dragable(0, -200, -200, 130, 120, 1, 10, 30);
	    
	    img[1] = getImage(getDocumentBase(), "tgraphics/newspaper.gif");
        tracker.addImage(img[1], 0);
        drag[1] = new dragable(1, -200, -200, 200, 142, 1, 160, 30);

        img[2] = getImage(getDocumentBase(), "tgraphics/juicebox.gif");
        tracker.addImage(img[2], 0);
        drag[2] = new dragable(2, -200, -200, 83, 100, 0, 390, 30);

        img[3] = getImage(getDocumentBase(), "tgraphics/plasticdrinkbottle.gif");
        tracker.addImage(img[3], 0);
        drag[3] = new dragable(3, -200, -200, 71, 180, 1, 40, 5);
        

        img[4] = getImage(getDocumentBase(), "tgraphics/bagofchips.gif");
        tracker.addImage(img[4], 0);
        drag[4] = new dragable(4, -200, -200, 170, 142, 0, 140, 30);

        img[5] = getImage(getDocumentBase(), "tgraphics/bananapeel.gif");
        tracker.addImage(img[5], 0);
        drag[5] = new dragable(5, -200, -200, 160, 62, 2, 325, 40);

        img[6] = getImage(getDocumentBase(), "tgraphics/styrofoamcup.gif");
        tracker.addImage(img[6], 0);
        drag[6] = new dragable(6, -200, -200, 85, 75, 0, 50, 30);

        img[7] = getImage(getDocumentBase(), "tgraphics/applecore.gif");
        tracker.addImage(img[7], 0);
        drag[7] = new dragable(7, -200, -200, 66, 100, 2, 200, 30);

        img[8] = getImage(getDocumentBase(), "tgraphics/candywrapper.gif");
        tracker.addImage(img[8], 0);
        drag[8] = new dragable(8, -200, -200, 116, 120, 0, 340, 30);

        img[9] = getImage(getDocumentBase(), "tgraphics/plasticcup.gif");
        tracker.addImage(img[9], 0);
        drag[9] = new dragable(9, -200, -200, 72, 80, 1, 70 ,40);


        img[10] = getImage(getDocumentBase(), "tgraphics/glassbottle.gif");
        tracker.addImage(img[10], 0);
        drag[10] = new dragable(10, -200, -200, 53, 200, 1, 230, 0);

        img[11] = getImage(getDocumentBase(), "tgraphics/eggshell.gif");
        tracker.addImage(img[11], 0);
        drag[11] = new dragable(11, -200, -200, 129, 80, 2, 340, 40);
        
       img[12] = getImage(getDocumentBase(), "tgraphics/papernapkin.gif");
        tracker.addImage(img[12], 0);
        drag[12] = new dragable(12, -200, -200, 105, 105, 2, 60, 30);

        img[13] = getImage(getDocumentBase(), "tgraphics/plasticbaggie.gif");
        tracker.addImage(img[13], 0);
        drag[13] = new dragable(13, -200, -200, 140, 73, 1, 200, 30);

        img[14] = getImage(getDocumentBase(), "tgraphics/halfeatensandwich.gif");
        tracker.addImage(img[14], 0);
        drag[14] = new dragable(14, -200, -200, 100, 89, 2, 380, 30);

        
        //runme = new Thread(this);
        //runme.start();

}




    public void update(Graphics g)
    {
        
 
               
       
        if(show)
        {
            //System.out.println("Show is true");
            og = offscrImg.getGraphics();
            og.setColor(back);
            og.fillRect(0, 0, size().width, size().height);
      
            //System.out.println("I am in update and show is true");
              

             if(startBucket.getX() != -200)
             {
            
                 og.setColor(Color.white);
                 og.fillRoundRect(60, 40, 520, 200, 80, 80);
                 og.setColor(back);
                 og.setFont(f42);
                 og.drawString("Instructions", 180, 90);
                 og.setColor(Color.black);
                 og.setFont(f18);
                 og.drawString(Instructions[0], 130, 120);
                 og.drawString(Instructions[1], 130, 140);
               
                    //firstDraw = false;
                    
                 og.drawImage(startImage, startBucket.getX(), startBucket.getY(), this); 
                
             }else{
          


               for(int buckCount = 0; buckCount < buckNum; buckCount++)
               {
                   og.drawImage(buckimg[buckCount], buck[buckCount].getX(), buck[buckCount].getY(), buck[buckCount].getW(), buck[buckCount].getH(), this);
               }

               for(int imgCount = 0; imgCount < imgNum; imgCount++)
               {
                   og.drawImage(img[imgCount], drag[imgCount].getX(), drag[imgCount].getY(), drag[imgCount].getW(), drag[imgCount].getH(), this);
               }




               if(gameover)
               {
                  //System.out.println("Game Over is true");
                  //og.drawImage(cowimg[0], 0, 100 ,this);

                  if( score <= 5 ){ mscore = 0; }
                  else if( score <= 10 ){ mscore = 1; }
                  else if( score <= 14 ){ mscore = 2; }
                  else if( score == 15 ){ mscore = 3; }
                  scoreString = "YOUR FINAL SCORE IS " + String.valueOf(score)+ "/15";

                  gameover = false;


               }

               og.drawImage(nextImage, nextRow.getX(), nextRow.getY(), this);
               
               

               og.setColor(Color.blue);
               og.setFont(f24);

               og.drawString(scoreString, 130, 80);

               og.setColor(Color.black);
               og.fillRoundRect(500, 238, 104, 44, 35, 35);
            
               og.setColor(Color.orange);
               og.fillRoundRect(502, 240, 100, 40, 35, 35);

               og.drawImage(startAgain, again.getX(), again.getY(), again.getW(), again.getH(),this);
               og.setFont(f24);
               og.setColor(Color.black);

               og.drawString("score:" + String.valueOf(score), 507, 267);

               if(mscore >= 0 && mscore < 4)
               {
                  og.setFont(f18);
                  og.setColor(Color.blue);
                  og.drawString(endMessage[mscore], 120, 110);
               }


   if(cowoncan)
               {
                
                    if( cow == 2 )
                    {
                       og.setColor(new Color(200, 0, 0));
                       oopsClip.play();
                    }else{    
                       og.setColor(new Color(0, 200, 0));
                       magicClip.play();
                    }
                        
                    og.fillRoundRect(40, 10, 620, 150, 80, 80);
                    og.setColor(new Color(255, 255, 200));
                    og.fillRoundRect(50, 20, 600, 130, 80, 80);
                    og.setColor(Color.black);
                    og.setFont(f18);
                    og.drawString(FunMessage, (this.size().width - fm.stringWidth(FunMessage))/2, 65);
                    if( cow == 2 )
                    {
                       og.setColor(new Color(200, 0, 0));
                    }else{    
                       og.setColor(new Color(0, 200, 0));
                    }
                    og.drawString(DoneMessage, (this.size().width - fm.stringWidth(DoneMessage))/2, 95);

                    og.drawImage(cowimg[cow], 525, 80 ,this);
                    cowoncan = false;
                    
               }else{

               }
               
               
               if(!firstDraw)
               {
                 
                  //System.out.println("First Draw is false");
                  for(int imgCount = 0; imgCount < imgNum; imgCount++)
                  {


                      if(dragable.draglock == imgCount)
                      {  
                          //System.out.println("dragable draglock = imgCount:" + imgCount );
                          clip(og, drag[imgCount].lastMouseX, drag[imgCount].lastMouseY, drag[imgCount].getX(), drag[imgCount].getY(), drag[imgCount].getW(), drag[imgCount].getH());
                          clip(g, drag[imgCount].lastMouseX, drag[imgCount].lastMouseY, drag[imgCount].getX(), drag[imgCount].getY(), drag[imgCount].getW(), drag[imgCount].getH());
                      }

                  }

               }
               
               

             }
           
           
           
             //paint(og);
             g.drawImage(offscrImg, 0, 0, this);
            
         
           
             og.dispose();
             //paint(g);

             


       }else{


           if(firstDraw)
           {
              g.setColor(back);
              g.fillRect(0, 0, size().width, size().height);
              firstDraw = false;
           }


           
           calcStart(g);
          
       }
       
        

    }

    void clip(Graphics g, int oldx, int oldy, int newx, int newy, int width, int height)
    {
        //System.out.println("I am in Clip Rect");
        int x = Math.min(oldx, newx) - 20; 
        int y = Math.min(oldy, newy) - 20;
        int w = (Math.max(oldx, newx) + width) - x;
        int h = (Math.max(oldy, newy) + height) - y;
        g.clipRect(x, y, w, h);

    }

    public void paint(Graphics g)
    {
        //System.out.println("I am in paint");
 
    }

    public void setNextRow()
    {
        int times = 0;
        for(int count = imggone; count < imggone + 3; count ++)
        {
            //drag[count].x = (180 * times) + 10;
            //times++;
            //drag[count].y = 50;
            drag[count].y = drag[count].rowY;
            drag[count].x = drag[count].rowX;

        }

        nextRow.x = -200;
        nextRow.y = -200;
        firstDraw = true;

    }


    public boolean mouseUp(Event e, int x, int y)
    {


      //if(x > 345 && x < 445 && y > 50 && y < 150 && cowoncan)
      if(cowoncan)
      {
          cowoncan = false;
          firstDraw = true;
          repaint();
      }


      if(startBucket.IsInside(x, y))
      {
         //can.setCan("");
         setNextRow();
         startBucket.x = -200;
         startBucket.y = -200;
         timer = 0;
      }
      if(nextRow.IsInside(x, y))
      {

        setNextRow();

      }

      for(int buckCount = 0; buckCount < buckNum; buckCount++)
      {
        for(int imgCount = 0; imgCount < imgNum; imgCount++)
        {
            if(drag[imgCount].IsInside(x, y))
            {

                if(buck[buckCount].IsInside(x, y))
                {
                    if(drag[imgCount].InOut != buckCount)
                    {

                        FunMessage = inoutMessage[imgCount];
                        cowoncan = true;

                        selbuck = buckCount;

                        cow = 2;
                        

                    }else{
                        score += 1;
                        cowoncan = true;
                        FunMessage = inoutMessage[imgCount];
                        selbuck = buckCount;

                        cow = 1;
                        

                    }









                    drag[imgCount].setPos(-100, -100);
                    imggone++;

                    if(imgNum == imggone)
                    {
                        gameover = true;
                        
                    }

                    if((imggone % 3) == 0 && !gameover)
                    {
                        nextRow.x = 250;
                        nextRow.y = 70;
                    }else{
                        nextRow.x = -200;
                        nextRow.y = -200;
                    }



                }

            }

        }
      }
      firstDraw = true;
      repaint();

      return true;

    }

    public boolean mouseDown(Event e, int x, int y)
    {

        //System.out.println("In mousedown IMG NUM IS " + imgNum);
        //System.out.println("In mousedown X IS " + x);
        //System.out.println("In mousedown Y IS " + y);
        repaint();
        for(int imgCount = 0; imgCount < imgNum; imgCount++)
        {
            if(drag[imgCount].IsInside(x, y))
            {
                 drag[imgCount].setMouseDown(x, y);
            }
        }

        if(again.IsInside(x, y))
          reInit();
        return true;

    }

    int dragc = 0;

    public boolean mouseDrag(Event e, int x, int y)
    {

        cow = 0;
        for(int imgCount = 0; imgCount < imgNum; imgCount++)
        {
            if(drag[imgCount].IsInside(x, y))
            {
                drag[imgCount].setPos(x, y);
                firstDraw = false;
                repaint();

                
            }
        }



        return true;

    }
    
    
    
    public void calcStart(Graphics g)
    {
        
           mult = (int)(Math.random() * 10 );
           if(px < 1)
           {
              px += mult;
           }else if(px > 300){
              px -= mult;
           }else{
              if(mult < 5)
              {
                 px -= (int)(Math.random() * 10 );
              }else{
                px += (int)(Math.random() * 10 );
              }
           }

           mult = (int)(Math.random() * 10 );
           if(py < 1)
           {
              py += mult;
           }else if(py > 300){
              py -= mult;
           }else{
              if(mult < 5)
              {
                 py += (int)(Math.random() * 10 );
              }else{
                py -= (int)(Math.random() * 10 );
              }
           }

           mult = (int)(Math.random() * 10 );
           if(ph < 10)
           {
              ph += mult;
           }else if(ph > 200){
              ph -= mult;
           }else{
              if(mult < 5)
              {
                 ph += (int)(Math.random() * 10 );
              }else{
                ph -= (int)(Math.random() * 10 );
              }
           }

           mult = (int)(Math.random() * 10 );
           if(pw < 10)
           {
              pw += mult;
           }else if(pw > 200){
              pw -= mult;
           }else{
              if(mult < 5)
              {
                 pw -= (int)(Math.random() * 10 );
              }else{
                pw += (int)(Math.random() * 10 );
              }
           }








           mult = (int)(Math.random() * 10 );
           if(qx < 1)
           {
              qx += mult;
           }else if(qx > 300){
              qx -= mult;
           }else{
              if(mult < 5)
              {
                 qx += (int)(Math.random() * 10 );
              }else{
                qx -= (int)(Math.random() * 10 );
              }
           }

           mult = (int)(Math.random() * 10 );
           if(qy < 1)
           {
              qy += mult;
           }else if(qy > 300){
              qy -= mult;
           }else{
              if(mult < 5)
              {
                 qy += (int)(Math.random() * 10 );
              }else{
                qy -= (int)(Math.random() * 10 );
              }
           }

           mult = (int)(Math.random() * 10 );
           if(qh < 10)
           {
              qh += mult;
           }else if(qh > 300){
              qh -= mult;
           }else{
              if(mult < 5)
              {
                 qh -= (int)(Math.random() * 10 );
              }else{
                 qh += (int)(Math.random() * 10 );
              }
           }

           mult = (int)(Math.random() * 10 );
           if(qw < 10)
           {
              qw += mult;
           }else if(qw > 300){
              qw -= mult;
           }else{
              if(mult < 5)
              {
                 qw -= (int)(Math.random() * 10 );
              }else{
                qw += (int)(Math.random() * 10 );
              }
           }








                      mult = (int)(Math.random() * 10 );
           if(rx < 1)
           {
              rx += mult;
           }else if(rx > 300){
              rx -= mult;
           }else{
              if(mult < 5)
              {
                 rx += (int)(Math.random() * 10 );
              }else{
                rx -= (int)(Math.random() * 10 );
              }
           }

           mult = (int)(Math.random() * 10 );
           if(ry < 1)
           {
              ry += mult;
           }else if(ry > 300){
              ry -= mult;
           }else{
              if(mult < 5)
              {
                 ry += (int)(Math.random() * 10 );
              }else{
                ry -= (int)(Math.random() * 10 );
              }
           }

           mult = (int)(Math.random() * 10 );
           if(rh < 10)
           {
              rh += mult;
           }else if(rh > 300){
              rh -= mult;
           }else{
              if(mult < 5)
              {
                 rh -= (int)(Math.random() * 10 );
              }else{
                rh += (int)(Math.random() * 10 );
              }
           }

           mult = (int)(Math.random() * 10 );
           if(rw < 10)
           {
              rw += mult;
           }else if(rw > 300){
              rw -= mult;
           }else{
              if(mult < 5)
              {
                 rw -= (int)(Math.random() * 10 );
              }else{
                rw += (int)(Math.random() * 10 );
              }
           }







           mult = (int)(Math.random() * 10 );
           if(rw < 10)
           {
              rw += mult;
           }else if(rw > 300){
              rw -= mult;
           }else{
              if(mult < 5)
              {
                 rw -= (int)(Math.random() * 10 );
              }else{
                 rw += (int)(Math.random() * 10 );
              }
           }



           mult = (int)(Math.random() * 10 );
           if(sy < 100)
           {
              sy += mult;
           }else if(sy > 200){
              sy -= mult;
           }else{
              if(mult < 5)
              {
                 sy += (int)(Math.random() * 10 );
              }else{
                sy -= (int)(Math.random() * 10 );
              }
           }

           mult = (int)(Math.random() * 10 );
           if(sx < 100)
           {
              sx += mult;
           }else if(sx > 200){
              sx -= mult;
           }else{
              if(mult < 5)
              {
                 sx += (int)(Math.random() * 10 );
              }else{
                sx -= (int)(Math.random() * 10 );
              }
           }




          if(mult <= 3)
          {
             g.setColor(Color.blue);
             g.drawOval(rx, ry, rw, rh);
             g.setColor(Color.green);
             g.drawOval(qx, qy, qw, qh);
             g.setColor(Color.red);
             g.drawOval(px, py, pw, ph);

          }else if(mult <= 6 && mult > 3){
            g.setColor(Color.blue);
            g.drawOval(rx, ry, rw, rh);
            g.setColor(Color.red);
            g.drawOval(px, py, pw, ph);
            g.setColor(Color.green);
            g.drawOval(qx, qy, qw, qh);

          }else{
            g.setColor(Color.red);
            g.drawOval(px, py, pw, ph);
            g.setColor(Color.blue);
            g.drawOval(rx, ry, rw, rh);
            g.setColor(Color.green);
            g.drawOval(qx, qy, qw, qh);


          }

            loopcount++;
            if(loopcount > 15)
            {
               loopcount = 0;
               a = (int)(Math.random() * 36);
               b = (int)(Math.random() * 255);
               c = (int)(Math.random() * 255);
               d = (int)(Math.random() * 255);
               e = (int)(Math.random() * 255);
               f = (int)(Math.random() * 255);
               h = (int)(Math.random() * 255);
               lmc = (int)(Math.random() * 5);


            g.setFont(f42);

            g.setColor(new Color(e, f, h));

            g.fillOval(46, 96, 307, 148);

            g.setColor(new Color( b, c, d));

            g.fillOval(50, 100, 300, 141);
            g.setColor(new Color(e, f, h));
            g.drawString("Please Wait!", 110, 160);
            g.setFont(f15);
            g.drawString(loadMessage[lmc], 130, 200);

            
            }



            paint(g);   
        
        
    }
    
    
}


class dragable extends bucket
{

    public static int draglock;
    public int InOut, lastMouseX, lastMouseY, id, rowX, rowY;

    dragable(int id, int x, int y, int w, int h, int InOut, int rowX, int rowY)
    {

        super(x, y, w, h);
        this.InOut = InOut;
        this.id = id;
        this.rowX = rowX;
        this.rowY = rowY;
    }


    void setMouseDown(int downX, int downY)
    {

          //cow = 0;
          draglock = id;
          lastMouseX = downX;
          lastMouseY = downY;


    }
    void setPos(int newMouseX, int newMouseY)
    {

        if(draglock == id)
        {
           x += newMouseX - lastMouseX;
           y += newMouseY - lastMouseY;

           lastMouseY = newMouseY;
           lastMouseX = newMouseX;
        }

    }


}

class bucket
{


    public int x, y, w, h;
    public int ox, oy, ow, oh;

    bucket(int x, int y, int w, int h)
    {

        this.x = x;
        this.y = y;
        this.w = w;
        this.h = h;
        ox = x;
        oy = y;
        ow = w;
        oh = h;
    }

    void reset()
    {
        x = ox;
        y = oy;
        w = ow;
        h = oh;

    }

    int getW()
    {
       return w;
    }

    int getH()
    {
       return h;
    }

    int getX()
    {
       return x;
    }

    int getY()
    {
       return y;
    }

    boolean IsInside(int mx, int my)
    {

        if(mx >= x && mx < (x + w) && my >= y && my <= (y + h))
        {

            return true;

        }else{

            return false;

        }

    }

}

class myCan extends Canvas
{

    private String curString;
    int x, y;
    Color mblue;
    //boolean rb;
    int ccount = 0;

    Color carr[] = new Color[6];


    myCan(int w, int h)
    {

        carr[0] = new Color(170, 70, 170);
        carr[1] = new Color(255, 255, 255);
        carr[2] = new Color(250, 150, 50);
        carr[3] = new Color(225, 25, 25);
        carr[4] = new Color(25, 25, 225);
        carr[5] = new Color(0, 0, 0);
        //resize(w, h);
        resize(290, 40);
        mblue = new Color(70, 170, 70);
        //mred = new Color(170, 70, 70);
        //rb = true;


    }


    public void setCan(String s)
    {

        curString = s;
        x = 10;
        y = 20;
        ccount++;
        if (ccount > 5)
        {
            ccount = 0;
        }
        //rb = !rb;


    }

    public void scroll(int amount)
    {

        x -= amount;
        this.repaint();


    }

    public void update(Graphics g)
    {

        this.paint(g);

    }

    public void paint(Graphics g)
    {
        //if(rb)
        //{
           //g.setColor(mblue);
        //}else{
           //g.setColor(mred);
        //}
        g.setColor(mblue);
        g.fillRect(0, 0, 300, 50);
        g.setColor(carr[ccount]);
        g.setFont(new Font("Dialog", Font.BOLD, 12));
        //g.clipRect(x, y, 300, 50);
        g.drawString(curString, x, y);



    }
    




}


