/*The user of the program inputs an integer, the maximum size of  the list. Thereafter, the user can input the following commands:		a  n    add String n to the list		d  n    delete String n from the list		?  n	report whether n is in the list		#		print the size of the list		p		print the list		q		quit*/import java.io.*;public class CUCSApplication {	public static void main(String args[]){	// initialize Text object in to read from standard input.		TokenReader in = new TokenReader(System.in);			String cmd;		// Last command read from input	String val;		// argument of command (if it has one)	List list;		// The test list	int	k;		// Request max size of list, read it in, and create the list		System.out.println("Enter max size of list");		System.out.flush();		list= new List(in.readInt());		// Process commands		System.out.println("Enter commands (q to stop)");		System.out.flush();		cmd= in.readString();		// Invariant cmd is the next command to process; its		//           argument has not been read in.		while (!cmd.equals("q")) {		  // Process command cmd			if (cmd.equals("a")) {				// The command is: Add next input String to list				val= in.readString();				list.add(val);				}			else if (cmd.equals("d")) {				// The command is: Delete next input String from list				val= in.readString();				list.delete(val);				}			else if (cmd.equals("?")) {				// The command is: Report whether next input String is in list				val= in.readString();				System.out.print(val + " is ");				if ( !list.isIn(val))					System.out.print("not ");				System.out.println("in list");				}			else if (cmd.equals("#")) {				// The command is: Report size of list				System.out.println("Size is: " + list.size());				}			else if (cmd.equals("p")) {				// Print the list				System.out.println("List is: " + list.toString());				}			else {				System.out.println("Unrecognized command: " + cmd);				}			cmd= in.readString();			}				// Wait for user to enter input to ensure console window remains visible			in.waitUntilEnter();		}}