Package | Class | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## Class ContactList

    java.lang.Object
      ContactList

    public class ContactList

extends Object

A linked list of ContactNodes that mimics a contact list or an address book

Constructor Summary
`ContactList()` Default constructor to create the list.
`ContactList(ContactNode head)` Constructor to create the list with a provided head of list.

Method Summary
`void` | `add(ContactNode contactToInsert)` Method to insert a new node into the list.
`boolean` | `delete(ContactNode node)` Method to delete a node from the list and return true if it was successful.
`ContactNode` | `getHead()` Method to return the variable head
`boolean` | `insertAfter(ContactNode node, ContactNode contactToInsert)` Method to insert a new node (with the ContactEntry contactToInsert as the data) after the specified node and return true if successful.
`ContactEntry` | `searchByEmail(String email)` Method to find and return the the first ContactEntry with the provided email
`ContactEntry` | `searchByName(String name)` Method to find and return the the first ContactEntry with the provided name
`ContactEntry` | `searchByPhone(String phone)` Method to find and return the the first ContactEntry with the provided phone number
`void` | `setHead(ContactNode head)` Method to set the variable head
`int` | `size()` Method to return the size of or the number of elements in the list
`String` | `toString()` Provides a String representation of the entire list by calling the toString of each item in the list.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### ContactList

    public ContactList()

  Default constructor to create the list. All instance variables are set to null

### ContactList

    public ContactList(ContactNode head)

  Constructor to create the list with a provided head of list. head is set to the incoming ContactNode

Method Detail

### getHead

    public ContactNode getHead()

  Method to return the variable head

  Returns:
    head

### setHead

    public void setHead(ContactNode head)

  Method to set the variable head

  Parameters:
    `head` - new head of the list

### add

    public void add(ContactNode contactToInsert)

  Method to insert a new node into the list. If the list is empty i.e. head equals null, then set the head equal to the new node.

  Parameters:
    `contactToInsert` - ContactNode that to be inserted

### insertAfter

    public boolean insertAfter(ContactNode node,
                               ContactNode contactToInsert)

  Method to insert a new node (with the ContactEntry contactToInsert as the data) after the specified node and return true if successful.

  Parameters:
    `node` - node to insert after
    `contactToInsert` - node that will be inserted after node
  Returns:
    true if insertion was successful, false otherwise.

### delete

    public boolean delete(ContactNode node)

  Method to delete a node from the list and return true if it was successful. param node the node to be deleted return true if the removal was successful

### searchByName

    public ContactEntry searchByName(String name)

  Method to find and return the the first ContactEntry with the provided name

  Parameters:
    `name` - the name to search for
  Returns:
    the first ContactEntry with the provided name, null if no ContactEntries fit the criteria

### searchByPhone

    public ContactEntry searchByPhone(String phone)

  Method to find and return the the first ContactEntry with the provided phone number

  Parameters:
    `phone` - the phone number to search for
  Returns:
    the first ContactEntry with the provided phone number, null if no ContactEntries fit the criteria

### searchByEmail

    public ContactEntry searchByEmail(String email)

  Method to find and return the the first ContactEntry with the provided email

  Parameters:
    `email` - the email to search for
  Returns:
    the first ContactEntry with the provided email, null if no ContactEntries fit the criteria

### size

    public int size()

  Method to return the size of or the number of elements in the list

  Returns:
    the size of the list

### toString

    public String toString()

  Provides a String representation of the entire list by calling the toString of each item in the list.

  Overrides:
    `toString` in class `Object`
  Returns:
    a String representation of the entire list

Package | Class | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD