

import java.awt.*;	// if you use any kind of graphics
import java.io.*;	// if you use any kind of I/O


public class myStack
{
final int MAX = 100;

myObject stack[];
int t; // top of the stack

public myStack()
{
stack = new myObject[MAX];
t = 0;
}//end myStack constructor

public void push(myObject o)
{
if (t != MAX) 
{
stack[t]=o;
t++;
}

}//end push

public myObject pop()
{

if (t>0) t--;
return(stack[t]);

}//end pop

public boolean isEmpty()
{

return(t == 0);

}//end IsEmpty



//*****************************
//
//   
// print the array on Java console
//
//
//*****************************

public void Print()
{
int i;

for (i = 0 ; i < t ; i++)
System.out.println(stack[i] + "  ");

}// end Print

//*****************************
//
//   
// Draw the stack
//
//
//*****************************

public void Draw(Graphics g)
{
int i;
int sum = 5;

// System.out.println("In stack Draw, t = " + t);

for (i = 0 ; i < t ; i++)
{
g.setColor(Color.red);
g.drawRect(sum, 60, 20, 40);
g.setColor(Color.black);
g.drawString(""+stack[i].o, sum+5, 60+25);
sum = sum + 20 + 5;

}// end for i

g.setColor(Color.red);

}// end Draw



//*****************************
//
//   
// Draw Rectangles of height given by an array of integers
//
//
//*****************************

public void DrawRect(Graphics g)
{
int i;
int sum = 5;


for (i = 0 ; i < t ; i++)
{
g.fillRect(sum, 60, stack[i].o, 40);
g.drawString(""+stack[i].o, sum+1, 60+0);
sum = sum + stack[i].o + 5;

}// end for i

}// end DrawRect



}//end class myStack