All pastes #404290 Raw Edit

Wolever

public java v1 · immutable
·published 2007-03-20 22:44 UTC
rendered paste body
/** Contact Directory System */public class Directory{    Contact_Temp[] contactList;    Contact_Temp temp;    int index;    int index_2;        //Constructor    public Directory ()    {        contactList = new Contact_Temp [100];    }    //This method checks if a contact can be added    public boolean checkToAddContact ()    {        if (index < 0)            return false;        else            return true;    }    //This method adds the contact    //Should the variable type be directory?    public void addContact (Contact_Temp temp)    {        //Adds the contact        contactList [index] = temp;        // Sets the new index;        for (int i = 0 ; i < 99 ; i++)        {            if (contactList [i] == null)            {                index = i;                break;            }            else                index = -1;        }        System.out.println ("Contact Added Successfully");    }    //is index my array? or my number in the contactlist?    //will it return to menu again?    public void deleteContact (Contact_Temp temp)    {        int index_2 = -1;        for (int i = 0 ; i < 100 ; i++)        {            //finds the contact and points it to null            if ((contactList [i].getIdennum ()).equals (temp.getIdennum()))            {                contactList [i] = null;                break;            }        }        // Sets the new index;        //i dont need all of this....right?        for (int i = 0 ; i < 99 ; i++)        {            if (contactList [i] == null)            {                index = i;                break;            }            else                index = -1;        }    }     //This method finds contact by UID    public Contact_Temp findContactByIdennum (String idennum)    {        String iddennum = temp.getIdennum (); //seeing if id numbersmatch        for (int i = 0 ; i < 99 ; i++)        {            if ((contactList [i].getIdennum ()).equals (idennum))            {                // If the contact is found                return contactList [i];                break;            }        }        // If the contact is not found        return null;    }    //which index is this?    public Contact_Temp findContactByName (String name)    {        int pointer = -1;        for (int i = 0 ; i < 99 ; i++)        {            if ((contactList [i].getName ()).equals (name))            {                pointer = i;                break;            }        }        return temp;        //return index or print student? i want to print the entire student    }    @@    public void printAllContacts ()    {        for (int i = 0 ; i < 100 ; i++)        {            contactList[i].printContact();          printContact (i);        }    }    // bubble sort algorithm applied to sorting contacts    public static void sortContactsByAlphabeticalOrder (String[] contactList)  //is it a string type?    {        boolean sorted = false;        for (int top = contactList.length - 1 ; top > 0 && !sorted ; top--) //check this        {            sorted = true;            for (int i = 0 ; i < top ; i++)            {                if (contactList [i].compareTo (contactList [i + 1]) > 0)                {                    sorted = false;                    String temp = contactList [i];                    contactList [i] = contactList [i + 1];                    contactList [i + 1] = temp;                }            }        }    }}