import java.applet.*;
import java.awt.*;

public class VarParams2 extends Applet
{
    final int FONTSIZE = 14;

    final int LEFTALN = 10;

    final int CHOICE01 = 60;
    final int CHOICE12 = 90;
    final int CHOICE23 = 120;
    final int CHOICE34 = 150;

    int choice;
    int cell;

    Font font1 = new Font("TimesRoman", Font.BOLD, FONTSIZE);
    Font font2 = new Font("TimesRoman", Font.BOLD, FONTSIZE*2);

	

//******************************************

    public void init()
    {
	setBackground(Color.white);
	choice = 0;
	cell = 0;
    }

//*******************************************

    public boolean mouseDown(Event e, int x, int y)
    {
	if ((y>CHOICE01) && (y<CHOICE12))
	    choice = 1;
	else if ((y>CHOICE12) && (y<CHOICE23))
	    choice = 2;
	else if ((y>CHOICE23) && (y<CHOICE34+15))
	    choice = 3;
	else
	    choice = 0;

	if ((x>100) && (x<190))
	    cell=1;
	else if ((x>191) && (x<280))
	    cell=2;
	else if ((x>281) && (x<370))
	    cell=3;
	else if (x<60)	
	    cell = 4;
	else
	    cell=0;

	repaint();
	return true;
    }

//*******************************************

    public void paint(Graphics g)
    {
	g.setFont(font1);
	g.setColor(Color.black);
	g.drawString("A", 222, CHOICE01-FONTSIZE-5);
	g.drawString("A[0]", 130, CHOICE01);
	g.drawString("A[1]", 220, CHOICE01);
	g.drawString("A[2]", 310, CHOICE01);
	g.drawRect(100, CHOICE01+8, 90, 90);
	g.drawRect(191, CHOICE01+8, 89, 90);
	g.drawRect(281, CHOICE01+8, 89, 90);
	g.drawString("Name", LEFTALN, (CHOICE01+CHOICE12)/2 + FONTSIZE);
	g.drawString("Value", LEFTALN, (CHOICE12+CHOICE23)/2 + FONTSIZE);
	g.drawString("Type", LEFTALN, (CHOICE23+CHOICE34)/2 + FONTSIZE);

	g.setFont(font2);
	g.drawString("17.2", 125, 100 + FONTSIZE);
	g.drawString("32.", 220, 100 + FONTSIZE);
	g.drawString("-5.2834", 282, 100 + FONTSIZE);

	g.setFont(font1);

	if (choice == 1) {
	    g.setColor(Color.magenta);
	    g.drawString("Name", LEFTALN, (CHOICE01+CHOICE12)/2 + FONTSIZE);
	    g.drawString("A", 222, CHOICE01-FONTSIZE-5);	
	    g.drawString("Name is attached to variable and memory cell",0, FONTSIZE);
	    choice =0;

	    if (cell==1) 
		g.drawString("A[0]", 130, CHOICE01);
	    else if (cell==2)
		g.drawString("A[1]", 220, CHOICE01);
	    else if (cell==3)
		g.drawString("A[2]", 310, CHOICE01);
	    cell = 0;
	}
	else if (choice==2)  {
	   g.setColor(Color.magenta);
	   g.drawString("Value", LEFTALN, (CHOICE12+CHOICE23)/2 + FONTSIZE);
	   g.setFont(font2);
	   if ((cell==1) || (cell==4))
		g.drawString("17.2", 125, 100 + FONTSIZE);
	   if ((cell==2) || (cell==4))
		g.drawString("32.", 220, 100 + FONTSIZE);
	   if ((cell==3) || (cell==4))
		g.drawString("-5.2834", 282, 100 + FONTSIZE);
	   g.setFont(font1);
	   g.drawString("Value is data actually stored in the memory cell",0,FONTSIZE);
	   choice = 0;
	   cell=0;
	}
	else if (choice==3) {
	  g.setColor(Color.magenta);
	  g.drawString("Type", LEFTALN, (CHOICE23+CHOICE34)/2 + FONTSIZE);
	  if ((cell==1) || (cell==4)) 
		g.drawRect(100, CHOICE01+8, 90, 90);
	  if ((cell==2) || (cell==4))
		g.drawRect(191, CHOICE01+8, 89, 90);
	  if ((cell==3) || (cell==4))
		g.drawRect(281, CHOICE01+8, 89, 90);

	  g.drawString("Type decides size of cell and interpretation of data", 0,FONTSIZE);
	  choice=0;	
	  cell=0;
	}
    }

}









