package calendar; import java.util.ArrayList; import java.util.Calendar; import javax.naming.directory.InvalidAttributesException; /** * @author Thomas Milner * @date 24/02/2012 * * @brief * This class holds the Contacts, it extends the Collection Object */ public class ContactsCollection extends Collection<Contact> { /** * Constructor, just sets the data arraylist to be the correct type. */ public ContactsCollection() { m_data = new ArrayList<Contact>(); } public int GetIndexById(int id) { for(int i = 0; i < m_data.size(); i++) { if(m_data.get(i).GetId() == id) return i; } return 0; } public static void main(String[] args) throws InvalidAttributesException{ ContactsCollection c = new ContactsCollection(); System.out.println("Before adding any contacts toCSV returns :" + c.ToCSV()); c.Add(new Contact(Data.AllocateEventId(), "John Smith", Calendar. getInstance(), "00000000000", "00000000000","00000000000", "john@spam.com", "john@spam.com", "joh.com")); System.out.println("After adding a contact toCSV returns :" + c. ToCSV()); c.Add(new Contact(Data.AllocateEventId(), "DrWho Smith", Calendar. getInstance(), "00000000000", "00000000000","00000000000", "Dr@spam.com", "Dr@spam.com", "Dr.com")); System.out.println("After adding another contact toCSV returns :" + c.ToCSV()); c.Remove(0); System.out.println("After removal of the event first contact toCSV " + "returns: " + c.ToCSV()); } }