import java.io.*;

/** 
 * program to test GenericWrapper and Iterator
 * @version 1.0, 29 August 2005
 * */
public class TestGenericWrapper {

	/**
	 * Main program
	 * inputs, stores, and outputs a GenericWrapper of Strings
	 * @throws IOException: an exception can occur in reading and if it does the exception should be thrown to the caller of this method instead of crashing the program
	 * 
	 */
	public static void main(String[] args) throws IOException{
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		GenericWrapper gW = new GenericWrapper(3);
		for(;;){
			System.out.println("New string: (just ENTER for quit inserting)");
			String iLine = stdin.readLine(); 
			if ((iLine ==null)  || iLine.equals("")) break;
			gW.add(iLine);
		}
		// print generic Wrapper contents
		System.out.println("GENERIC WRAPPER CONTENTS");
		java.util.Iterator i1, i2;
		for (i1 = gW.iterator(); i1.hasNext();){
			String oLine = (String) i1.next();
			System.out.println(oLine);
		}
		// delete last string
		i1.remove();
		// print the wrapper without the last element
		System.out.println("\nGENERIC WRAPPER CONTENTS WITHOUT LAST STRING");
		for (i2 = gW.iterator(); i2.hasNext();){
			String oLine = (String) i2.next();
			System.out.println(oLine);
		}
	}
}
