import java.util.*; public class ArrayCollectionTester implements Process { protected static final String INPUT_PROMPT = "In the Input line, please enter the method identifier " + "and, if applicable, the argument."; protected GUI gui; protected ArrayCollection myCollection = new ArrayCollection(); public ArrayCollectionTester() { gui = new GUI (this); gui.println (INPUT_PROMPT); } // constructor public void processInput (String s) { final String ADDED = "The element has been added to the ArrayCollection."; final String NOT_ADDED = "The element has not been added to the ArrayCollection " + "because it would\n have been a duplicate, and duplicates " + "are not allowed."; final String CONTAINED = "The element is contained in the ArrayCollection."; final String NOT_CONTAINED = "The element is not contained in the ArrayCollection."; final String EMPTY = "The ArrayCollection is empty."; final String NOT_EMPTY = "The ArrayCollection is not empty."; String operation, element; StringTokenizer tokens = new StringTokenizer (s); operation = tokens.nextToken(); if (operation.equals ("isEmpty")) if (myCollection.isEmpty()) gui.println (EMPTY); else gui.println (NOT_EMPTY); else { element = tokens.nextToken(); if (operation.equals ("add")) if (myCollection.add (element)) gui.println (ADDED); else gui.println (NOT_ADDED); else if (operation.equals ("contains")) if (myCollection.contains (element)) gui.println (CONTAINED); else gui.println (NOT_CONTAINED); } // operation add or contains gui.println ("\n\n" + INPUT_PROMPT); } // method processInput } // class ArrayCollectionTester