

import java.awt.*;
import java.applet.*;
import java.awt.FontMetrics;


public class InOut extends Applet implements Runnable
{
    int fdc;

    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 = 20;
    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[11];
    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("TimesRoman", Font.BOLD, 15);
	   f18 = new Font("TimesRoman", Font.BOLD, 18);
	   f24 = new Font("TimesRoman", Font.BOLD, 24);
	   f42 = new Font("TimesRoman", Font.BOLD, 42);

	   fm = getFontMetrics(f18);

	   DoneMessage = "Click the cow 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 milk can "; 
       Instructions[1] = "('in', 'out', or 'no cow') and drop it. To"; 
       Instructions[2] = "drag and drop, position the mouse pointer"; 
       Instructions[3] = "over the item you want to drag, click and";
       Instructions[4] = "hold down on the left mouse button, move the"; 
       Instructions[5] = "item by moving your mouse, then release"; 
       Instructions[6] = "the button to drop your item. ";

       inoutMessage[0] = "Pepper has nothing to do with a cow!";
       inoutMessage[1] = "A cow will eat about 100 lbs. of grass a day."; 
       inoutMessage[2] = "A dairy cow drinks 35 gal. of water daily";
       inoutMessage[3] = "Cows eat ground corn, soybeans, wheat, barley or oats.";
       inoutMessage[4] = "Cows eat ground corn, soybeans, wheat, barley or oats.";
       inoutMessage[5] = "A cow can eat up to 25 lbs. of hay a day";
       inoutMessage[6] = "Cows need to breath fresh air.";
       inoutMessage[7] = "Cow hide is used to make pet products like chew bones.";
       inoutMessage[8] = "Eggs Have nothing to do with a cow!";
       inoutMessage[9] = "Cow bones may be ground for use in livestock feed";
       inoutMessage[10] = "Margarine has nothing to do with a cow!";
       inoutMessage[11] = "Cows can produce from 4 to 20 gallons a day.";
       inoutMessage[12] = "A cow produces  about 3 ˝ gal. daily";
       inoutMessage[13] = "Cows lick salt blocks";
       inoutMessage[14] = "Cow hide (skin) makes good leather for shoes and coats.";
       inoutMessage[15] = "A steer can produce about 450 lbs. of meat";
       inoutMessage[16] = "Cattle eat apples, broccoli, pumpkins and more.";
       inoutMessage[17] = "Americans eat 1,000 lbs. of cheese in a lifetime.";
       inoutMessage[18] = "A cow can poop up to 15 times a day.";
       inoutMessage[19] = "A cow’s temperature  is 101.5F";
       



       endMessage[0] = "Try again! That was udderly terrible. ";
       endMessage[1] = "You don't know your cow pie from your apple pie!";
       endMessage[2] = "Ooops! You just stepped in a meadow muffin!";
       endMessage[3] = "Go back to Kow Kindergarten and try again!";;
       endMessage[4] = "Not too bad. Go talk to a cow and try again.";
       endMessage[5] = "Pretty good! Brush up on your cow facts and try again.";
       endMessage[6] = "Good score! You get a big wet cow kiss.";
       endMessage[7] = "Nice work! You get the four hoof salute.";
       endMessage[8] = "Great score! A toast to you(with a big glass of milk)!";
       endMessage[9] = "Congratulations!!! You are MOOOOOOO-st excellent!!!";
       endMessage[10] = "";

       loadMessage[0] = "Cows are the Coolest!";
       loadMessage[1] = "The cow game is loading!";
       loadMessage[2] = "Don't MOOOO-ve it's coming!";
       loadMessage[3] = "This game is FUN!";;
       loadMessage[4] = "Cow in and out game coming up!";



	    tracker = new MediaTracker(this);

	    back = new Color(70, 170, 70);
	    offscrImg = createImage(size().width, size().height);

	    again = new bucket(0, size().height-79, 77, 79);
	    startAgain = getImage(getDocumentBase(), "graphics/startagain.gif");
	    tracker.addImage(startAgain, 0);

	    funFact = getImage(getDocumentBase(), "graphics/funfact.gif");
	    tracker.addImage(funFact, 0);


	    startBucket = new bucket(320, 220, 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(), "graphics/coolcowyes.gif");
	    tracker.addImage(cowimg[1], 0);
	    cowimg[2] = getImage(getDocumentBase(), "graphics/coolcowno.gif");
	    tracker.addImage(cowimg[2], 0);

	    buckimg[0] = getImage(getDocumentBase(), "graphics/intocow.gif");
	    tracker.addImage(buckimg[0], 0);
	    buckimg[1] = getImage(getDocumentBase(), "graphics/fromcow.gif");
        tracker.addImage(buckimg[1], 0);
	    buckimg[2] = getImage(getDocumentBase(), "graphics/nocow.gif");
	    tracker.addImage(buckimg[2], 0);


	    buck[0] = new bucket(125, size().height-140, 112, 140);
	    buck[1] = new bucket(250, size().height-140, 112, 140);
	    buck[2] = new bucket(375, size().height-140, 112, 140);
	    
	    img[0] = getImage(getDocumentBase(), "graphics/pepper.gif");
        tracker.addImage(img[0], 0);
        drag[0] = new dragable(0, -200, -200, 61, 73, 2);
	    
	    img[1] = getImage(getDocumentBase(), "graphics/grass.gif");
        tracker.addImage(img[1], 0);
        drag[1] = new dragable(1, -200, -200, 61, 50, 0);

        img[2] = getImage(getDocumentBase(), "graphics/water.gif");
        tracker.addImage(img[2], 0);
        drag[2] = new dragable(2, -200, -200, 80, 51, 0);

        img[3] = getImage(getDocumentBase(), "graphics/corn.gif");
        tracker.addImage(img[3], 0);
        drag[3] = new dragable(3, -200, -200, 56, 89, 0);
        

        img[4] = getImage(getDocumentBase(), "graphics/wheat.gif");
        tracker.addImage(img[4], 0);
        drag[4] = new dragable(4, -200, -200, 61, 93, 0);

        img[5] = getImage(getDocumentBase(), "graphics/hay.gif");
        tracker.addImage(img[5], 0);
        drag[5] = new dragable(5, -200, -200, 58, 75, 0);

        img[6] = getImage(getDocumentBase(), "graphics/air.gif");
        tracker.addImage(img[6], 0);
        drag[6] = new dragable(6, -200, -200, 62, 53, 0);

        img[7] = getImage(getDocumentBase(), "graphics/bone.gif");
        tracker.addImage(img[7], 0);
        drag[7] = new dragable(7, -200, -200, 87, 58, 1);

        img[8] = getImage(getDocumentBase(), "graphics/eggs.gif");
        tracker.addImage(img[8], 0);
        drag[8] = new dragable(8, -200, -200, 71, 53, 2);

        img[9] = getImage(getDocumentBase(), "graphics/bonemeal.gif");
        tracker.addImage(img[9], 0);
        drag[9] = new dragable(9, -200, -200, 49, 58, 1);


        img[10] = getImage(getDocumentBase(), "graphics/margarine.gif");
        tracker.addImage(img[10], 0);
        drag[10] = new dragable(10, -200, -200, 67, 43, 2);

        img[11] = getImage(getDocumentBase(), "graphics/milk.gif");
        tracker.addImage(img[11], 0);
        drag[11] = new dragable(11, -200, -200, 43, 86, 1);
        
       img[12] = getImage(getDocumentBase(), "graphics/urine.gif");
        tracker.addImage(img[12], 0);
        drag[12] = new dragable(12, -200, -200, 81, 35, 1);

        img[13] = getImage(getDocumentBase(), "graphics/salt.gif");
        tracker.addImage(img[13], 0);
        drag[13] = new dragable(13, -200, -200, 61, 73, 0);

        img[14] = getImage(getDocumentBase(), "graphics/shoe.gif");
        tracker.addImage(img[14], 0);
        drag[14] = new dragable(14, -200, -200, 94, 55, 1);

        img[15] = getImage(getDocumentBase(), "graphics/steak.gif");
        tracker.addImage(img[15], 0);
        drag[15] = new dragable(15, -200, -200, 74, 57, 1);

        img[16] = getImage(getDocumentBase(), "graphics/fruit.gif");
        tracker.addImage(img[16], 0);
        drag[16] = new dragable(16, -200, -200, 46, 65, 0);

        img[17] = getImage(getDocumentBase(), "graphics/cheese.gif");
        tracker.addImage(img[17], 0);
        drag[17] = new dragable(17, -200, -200, 56, 43, 1);

        img[18] = getImage(getDocumentBase(), "graphics/manure.gif");
        tracker.addImage(img[18], 0);
        drag[18] = new dragable(18, -200, -200, 83, 43, 1);

        img[19] = getImage(getDocumentBase(), "graphics/heat.gif");
        tracker.addImage(img[19], 0);
        drag[19] = new dragable(19, -200, -200, 58, 50, 1);
        
        //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(10, 30, 480, 240, 80, 80);
                 og.setColor(back);
                 og.setFont(f42);
                 og.drawString("Instructions", 120, 70);
                 og.setColor(Color.black);
                 og.setFont(f18);
                 og.drawString(Instructions[0], 60, 100);
                 og.drawString(Instructions[1], 60, 120);
                 og.drawString(Instructions[2], 60, 140);
                 og.drawString(Instructions[3], 60, 160);
                 og.drawString(Instructions[4], 60, 180);
                 og.drawString(Instructions[5], 60, 200);
                 og.drawString(Instructions[6], 60, 220);
                    //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);


                  mscore = (int)(score/2) - 1;
                  scoreString = "YOUR FINAL SCORE IS " + String.valueOf(score)+ "/20";

                  gameover = false;


               }

               og.drawImage(nextImage, nextRow.getX(), nextRow.getY(), this);
               
               

               og.setColor(Color.blue);
               og.setFont(f24);

               og.drawString(scoreString, 130, 80);


               og.drawImage(startAgain, again.getX(), again.getY(), again.getW(), again.getH(),this);
               og.setFont(f18);
               og.setColor(Color.yellow);

               og.drawString("Points: " + String.valueOf(score), 18, 175);

               if(mscore >= 0 && mscore < 10)
               {
                  og.setFont(f15);
                  og.setColor(Color.orange);
                  og.drawString(endMessage[mscore], 120, 110);
               }



               if(cowoncan)
               {
                    og.setColor(Color.red);
                    og.fillRoundRect(0, 10, 500, 120, 80, 80);
                    og.setColor(Color.yellow);
                    og.setFont(f18);
                    og.drawString(FunMessage, (this.size().width - fm.stringWidth(FunMessage))/2, 45);
                    og.setColor(Color.green);
                    og.drawString(DoneMessage, (this.size().width - fm.stringWidth(DoneMessage))/2, 75);

                   og.drawImage(cowimg[cow], 345, 50 ,this);
               }else{
                   og.drawImage(cowimg[0], 0, 50 ,this);
               }
               
               
               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 = 1;
        for(int count = imggone; count < imggone + 4; count ++)
        {
            drag[count].x = (100 * times) + 10;
            times++;
            drag[count].y = 50;

        }

        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)
      {
          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 % 4) == 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, 407, 148);

            g.setColor(new Color( b, c, d));

            g.fillOval(50, 100, 400, 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;

    dragable(int id, int x, int y, int w, int h, int InOut)
    {

        super(x, y, w, h);
        this.InOut = InOut;
        this.id = id;
    }


    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);



    }
    




}


