import java.util.ArrayList;
public class ContactList
{
private ArrayList<Contact> contactList;
private String contactType;
public ContactList()
{
contactList = new ArrayList<Contact>();
}
public void addPersonalContact(String fName, String sName, String street, String town, String partOnePC, String partTwoPC, String phoneNumber)
{
contactList.add(new AddPersonalContact(fName, sName, street, town, partOnePC, partTwoPC, phoneNumber));
}
public void addBusinessContact(String fName, String sName, String street, String town, String partOnePC, String partTwoPC, String eMail)
{
contactList.add(new AddBusinessContact(fName, sName, street, town, partOnePC, partTwoPC, eMail));
}
public String toString() {
final StringBuilder output = new StringBuilder("All Contacts:\n");
for (Contact contact : contactList) {
output.append(contact).append("\n\n");
}
return output.toString();
}
public String getPersonalContacts()
{
String output = "All Personal Contacts:\n";
for (Contact contact : contactList)
{
if(contact instanceof AddPersonalContact)
{
output = output + contact + "\n\n" ;
}
}
return output;
}
public String getBusinessContacts()
{
String output = "All Business Contacts:\n";
for (Contact contact : contactList)
{
if(contact instanceof AddBusinessContact)
{
output = output + contact + "\n\n" ;
}
}
return output;
}
}