import java.applet.*;
import java.awt.*;
import java.awt.image.*;

public class tv extends Applet {
  Image curr[];
  MediaTracker tracker;
  Dimension d;
  int c;
  String cs;
  int h[]=new int[4];
  int v[]=new int[4];
  int a[]=new int[4];
  int b[]=new int[4];

  public void init() {
    tracker = new MediaTracker(this);
    curr = new Image[7];
    curr[0]=getImage(getDocumentBase(),"cactus5.gif");
    curr[1]=getImage(getDocumentBase(),"cactus7.gif");
    curr[2]=getImage(getDocumentBase(),"cactus6.gif");
    curr[3]=getImage(getDocumentBase(),"sun2.gif");
    curr[4]=getImage(getDocumentBase(),"thunder.gif");
    curr[5]=getImage(getDocumentBase(),"scorpion.gif");
    curr[6]=getImage(getDocumentBase(),"chili2.gif");
   for(int i=0; i<7; i++) tracker.addImage(curr[i],0);
    try { tracker.waitForAll();
    } catch(InterruptedException e) {
      showStatus("Interrupted while loading images.");
    }
    showStatus("Images Loaded");
    d=size();
    c=6;
    cs="66";
    h[0]=60;    h[1]=70;    h[2]=55;    h[3]=45;
    v[0]=120;   v[1]=120;   v[2]=145;   v[3]=145;
    a[0]=130;   a[1]=140;   a[2]=155;   a[3]=145;
    b[0]=120;   b[1]=120;   b[2]=145;   b[3]=145;
  }

  public boolean mouseDown(Event evt, int x, int y) {
   if((x>d.width-40)&&(x<d.width-30)&&(y>50)&&(y<60)) {
     c++;
     if(c>6) c=0;
     cs=String.valueOf((c+1));
     repaint();
   }
   return super.mouseDown(evt,x,y);
}

  public void paint(Graphics g) {
    g.setColor(Color.red);
    g.fillRect(0,0,d.width,d.height);
    g.setColor(Color.blue);
    g.fillRect(10,10,d.width-20,d.height-20);
    g.setColor(Color.black);
    g.drawRect(50,20,100,100);
    g.drawRect(20,20,160,100);
    g.fillRect(20,20,30,100);
    g.fillRect(150,20,30,100);
    g.fillRect(20,20,160,6);
    g.fillRect(20,114,160,6);
    Polygon rt=new Polygon(h,v,4);
    Polygon lt=new Polygon(a,b,4);
    g.fillPolygon(rt);
    g.fillPolygon(lt);
    g.setColor(Color.yellow);
    g.fillOval(d.width-40,50,10,10);
    g.fillOval(d.width-40,70,10,10);
    g.fillOval(d.width-40,30,10,10);
    g.drawString(cs,d.width-40,100);
    g.drawImage(curr[c],60,30,this);
  }
}
