/**
 * @author Dave
 */
public class AssertExamples{
	
	public static void main(String[] args){
		badTest();
	}
	
	/**
	 * A test of copyArray that should fail
	 */
	public static void badTest(){
		String[] src = new String[15];
		String[] dest = new String[10];
		
		copyArray(src, dest);
		System.out.println("test passed!");
	}
	
	/**
	 * A test of copy array that should pass
	 */
	public static void goodTest(){
		String[] src = new String[10];
		String[] dest = new String[10];
		
		copyArray(src, dest);
		System.out.println("test passed!");
	}
	
	/** 
	 * copies one array into another 
	 * 
	 * @param src the source array to copy from
	 * @param dest the destination array to copy to
	 * 
	 * @pre the length of src is not greater than the length of dest
	 * @post src contains a (shallow) copy of dest and any entries in dest not copied to are 
	 * set to null
	 */ 
	public static void copyArray(String[] src, String[] dest) { 
		assert src.length <= dest.length;
		int i = 0; 
		
		// copy over the data from src to the corresponding indices in 
		for (; i < src.length; i++){
			dest[i] = src[i];
		}
		
		// null out the remaining entries in dest if there are more entries
		for (; i < dest.length; i++) 
			dest[i] = null; 
	} 
}
