//An implementation of the StringStack interface that uses // a (small) array as the actual data store. public class mySS implements StringStack { String [] stuff; int nextSpot = 0; final static int MAX_SIZE = 10; mySS() { // Default constructor makes an array that can point at strings! stuff = new String[MAX_SIZE]; } public void push( String element) { if( nextSpot == MAX_SIZE) { System.out.println("Error! Array is too small!"); } stuff[ nextSpot ] = element; nextSpot = nextSpot + 1; } public String peek() { if (nextSpot == 0 ) { // nothing to return! return( null ); } return( stuff[nextSpot -1 ] ); } public String pop() { if (nextSpot == 0 ) { // nothing to return! return( null ); } nextSpot = nextSpot -1; return( stuff[nextSpot] ); } public int size() { return( nextSpot ); } public boolean isEmpty() { return( nextSpot == 0); // if ( nextSpot == 0) { // return true; // } else { // return false; // } } // end isEmpty }