package authoring.model.collections;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import data.Observable;

/**
 * General Collection is the abstract superclass for all collections held in the game. Uses generics to share common behavior.
 * @author Arjun Jain
 *
 * @param <T> The generic type of object we want to make a collection of.
 */
public abstract class GeneralCollection<T> extends Observable implements Iterable<T> {
	
	//it can be protected so that all subclasses can access it, tradeoff for repeated code reduction
	protected List<T> myObjects;

	public GeneralCollection(){
		myObjects = new ArrayList<T>();
	}
	
	
	@Override
	public Iterator<T> iterator() {
		return myObjects.iterator();
	}
	
	public T get(int i){
		return myObjects.get(i);
	}
	
	public boolean remove(T a){
		return myObjects.remove(a);
	}
	
	public void add(T a){
		myObjects.add(a);
		setChanged();
		notifyObservers(a);
	}
	
	public void addAll(GeneralCollection<T> collection){
	    myObjects.addAll(collection.myObjects);
	}
	
	public String toString(){
		return myObjects.toString();
	}
	
}

@@ -847,30 +847,37 @@
 ove(T a)%7B%0A%09%09
-return
+boolean ret =
  myObjects.r
@@ -882,24 +882,76 @@
 .remove(a);%0A
+%09%09setChanged();%0A%09%09notifyObservers(a);%0A%09%09return ret;%0A
 %09%7D%0A%09%0A%09public

remove now notifies observers