package sajous.litl.geom;

import java.util.*;

public class Group extends GeomObject
{
	private List<GeomObject> objList = new ArrayList<GeomObject>();
	
	public Group ()
	{
	} // Group ()
	
	public Group (String groupName)
	{
		setObjName(groupName);
	} // Group ()
	
	public void addObj (GeomObject obj)
	{
		objList.add(obj);
	} // addObj ()
	
	public void removeObj (GeomObject obj)
	{
		if (objList.contains(obj))
			objList.remove(obj);
		else
			System.out.println("Group/removeObj(): Attention ! Tentative de supprimer l'objet "
					+ obj.toString() + " du groupe "
					+ toString()
					+ " qui ne le contient pas.");
	} // removeObj ()

	public String toString ()
	{
		String result = getObjName() + " [Group:";
		
		// pour chaque objet du groupe, on ajoute
		// la representation textuelle de l'objet
		// a la chaine result
		Iterator<GeomObject> it = objList.iterator();
		while (it.hasNext())
		{
			GeomObject gObj = it.next();
			result += ("\n\t" + gObj.toString());
		} // while (it.hasNext())
		
		result += "]";
		
		return result;
	} // toString ()
} // class Group
