import java.io.*;
import java.util.*;

public class Lab9
{
	public static void main( String args[] ) throws Exception
	{
		BufferedReader infile1 = new BufferedReader( new FileReader( args[0] ) );
		BufferedReader infile2 = new BufferedReader( new FileReader( args[1] ) );

		String[] set1 = loadSet( infile1 );
		Arrays.sort( set1 );
		String[] set2 = loadSet( infile2 );
		Arrays.sort( set2 );
		printSet( "set1: ",set1 );
		printSet( "set2: ",set2 );

		String[] union = union( set1, set2 );
		Arrays.sort( union );
		printSet( "\nunion: ", union );


		String[] intersection = intersection( set1, set2 );
		Arrays.sort( intersection );
		printSet( "\nintersection: ",intersection );

		String[] difference = difference( set1, set2 );
		Arrays.sort( difference );
		printSet( "\ndifference: ",difference );

		String[] xor = xor( set1, set2 );
		Arrays.sort( xor );
		printSet("\nxor: ", xor );

		System.out.println( "\nSets Echoed after operations.");

		printSet( "set1: ", set1 );
		printSet( "set2: ", set2 );

	}// END MAIN

	// USE AS GIVEN - DO NOT MODIFY
	// CAVEAT: This method will not work *correctly* until you write a working doubleLength() method.

	static String[] loadSet( BufferedReader infile ) throws Exception
	{
		final int INITIAL_LENGTH = 5;
		int count=0;
		String[] set = new String[INITIAL_LENGTH];
		while( infile.ready() )
		{
				if (count >= set.length)
					set = upSize( set );
				set[ count++ ] = infile.readLine();
		}
		infile.close();
		return downSize( set, count );
	}

	// USE AS GIVEN - DO NOT MODIFY
	static void printSet( String caption, String [] set )
	{
		System.out.print( caption );
		for ( String s : set )
			System.out.print( s + " " );
		System.out.println();
	}
	/* ###############################################################
		For each of the following set operations you must execute the following steps:
		1) dimension an array that is just big enough to handle the largest possible set for that operation.
		2) add the appropriate elements to the array as the operation prescribes.
		3) before returning the array, resize it to the exact size as the number of elements in it.
	*/

	static boolean contains( String[] set, String key )
	{
		use an enhanced for loop to compare this key to 
		every element in the set if you find a match immed return TRUE
		
		if you make it out of the loop you must return FALSE
	}
	static String[] union( String[] set1, String[] set2 )
	{
		String[] unionResult = new String[ sum of the lengths]
		int count=0;
		
		use an enhanced for loop to walk across set1 and append
		every element from set1 onto the result;
		
		use an enhanced for loop to walk across set2 and append
		only those elements from set2 onto the result IF they
		are NOT contained in set1
		
		return the trim of unionResult, count ;
	}

	static String[] intersection( String[] set1, String[] set2 )
	{
		String[] interResult = new String[ the smaller ]
		int count=0;
		
		use an enhanced for loop to loop over set1 
		and test for contains of each set1 emlement in set2 the other set.
		
		only append elements that ARE contained in the other set
		
		return a trim of the result 
		
	}

	static String[] difference( String[] set1, String[] set2 )
	{
		how big does the diffREsult need to be?  set1 :)
		
		enhanced for loop only append elements of set1 that are NOT
		in set2 
		
		return a trim of the rsult 
	}

	static String[] xor( String[] set1, String[] set2 )
	{
		return null; // change this to return a trimmed full array
		** THE ENTIRE CODE OF THIS METHOD MUST BE A SINGLE 1 LINE RETURN STATEMENT
		** NOT ALLED TO DEFINE **ANY** VARIBLES OR ARRAYS IN HERE
		** NO LOOPS ALOWED
		** NO METHODS ALLOWED TO BE CALLED EXCEPT  UNION INTERSECTION AND DIFFERENCE
		** ALL THIS IN ONE SINGLE RETURN STATMENT 1 LINE OF CODE 1 FUNCTION CALL
	}

	// return an array of length 2x with all data from the old array stored in the new array
	static String[] upSize( String[] old )
	{
		return null; // you change accordingly
	}

	// return an array of length==count with all data from the old array stored in the new array
	static String[] downSize( String[] old, int count )
	{
		return null; // you change accordingly
	}

} // END CLASS