package Strategy;

import java.util.ArrayList;

import allocation.Allocation;
import users.User;

public class Strategy<T> {
	
	public ArrayList<T> add(ArrayList<T> a, T t){
		if(a == null) 
			a = new ArrayList<T>();
		a.add(t);
		return a;
	}
	
	public Object search (ArrayList<T> a, String key) {
		T found = null;
		if(a!=null) {
			for (T t : a) {
				try {	
					
					Allocation x = (Allocation) t;
					if(x.getName().equals(key) || x.getCode().equals(key) || x.getName().substring(0, 5).equals(key)) {
						found = (T) x;
						break;
					}
											
				}catch(ClassCastException exception) {
					
					try {
						
						User x = (User) t;
						if(x.getName().equals(key) || x.getID().equals(key)) {
							found = (T) x;
							break;
						}
						
					}catch(ClassCastException excepition) {
						
						String s = (String) t;
						if(s.equals(key)) {
							found = (T) s;
							break;
						}
						
					}
				}			
			}
		}
		return found;
	}
	
	public void delete (ArrayList<T> a, T t) {
		a.remove(a.indexOf(t));
		System.out.println("Removed from list");
	}
	
	public void delete (ArrayList<T> a, int index) {
		a.remove(index);
		System.out.println("Removed from list");
	}
	
}

@@ -1017,255 +1017,8 @@
 %0D%0A%09%7D
-%0D%0A%09%0D%0A%09public void delete (ArrayList%3CT%3E a, T t) %7B%0D%0A%09%09a.remove(a.indexOf(t));%0D%0A%09%09System.out.println(%22Removed from list%22);%0D%0A%09%7D%0D%0A%09%0D%0A%09public void delete (ArrayList%3CT%3E a, int index) %7B%0D%0A%09%09a.remove(index);%0D%0A%09%09System.out.println(%22Removed from list%22);%0D%0A%09%7D%0D%0A
 %09%0D%0A%7D

Update Strategy.java