public class Driver { int index; static String name, address, businessType, email; static String contactNum1, contactNum2, contactNum3; static String idennum, option; static String description1, description2, description3, comment; static double credit, accountBalance; static private Directory contactList = new Directory (); static private Contact_Temp temp; //check contructor /**this method creates a new contact*/ public void createContact () { boolean check = contactList.checkToAddContact (); if (check) { //Implement code for adding contact temp = new Contact_Temp (name, idennum, address, businessType, email, contactNum1, description1, contactNum2, description2, contactNum3, description3, comment, credit, accountBalance); } else { System.out.println ("Could not add contact. Please Try again"); } } /** this method prints the menu */ public static void printMenu () { System.out.println ("Welcome to the Contact Directory System\n"); System.out.println ("1) Add a new contact"); System.out.println ("2) Delete a contact by UID"); System.out.println ("3) Display contact by UID"); System.out.println ("4) Search by Name"); System.out.println ("5) Show all contacts"); System.out.println ("6) Show contact by business type"); System.out.println ("7) Sort all contacts by Name and display"); System.out.println ("8) Sort contacts by specific business type and display"); System.out.println ("9) Add Balance to contact"); System.out.println ("10) Add credit to contact"); System.out.println ("11) Show balance for contact"); System.out.println ("12) Show credit for contact"); System.out.println ("13) Show total balance"); System.out.println ("14) Show total credit"); System.out.println ("15) Show total positive balance"); System.out.println ("16) Show total negative balance"); System.out.println ("17) Show the contact with highest positive balance"); System.out.println ("18) Show the contact with highest negative balance"); System.out.println ("19) Show the contact with highest credit"); System.out.println ("20) Quit\n"); System.out.println ("please select an option:"); } public static void main (String[] args) { int option; int choiceOfBusinessType; for (;;) //infinite for loop, can always go back to menu { printMenu (); option = In.getInt (); //adds a new contact if (option == 1) { System.out.println ("Enter contact's name"); name = In.getString (); System.out.println ("Enter contact's ID number"); idennum = In.getString (); System.out.println ("Enter contact's address"); address = In.getString (); System.out.println ("Choose one of the following business types"); System.out.println ("Education\n shipping\n supplier\n buyer\n broker\n Airline Agency\n Financial Services\n Other\n"); businessType = In.getString (); System.out.println ("Enter the contact's email address"); email = In.getString (); System.out.println ("Enter the first contact number"); contactNum1 = In.getString (); System.out.println ("Enter the description of this number"); description1 = In.getString (); System.out.println ("Enter the second contact number"); contactNum2 = In.getString (); System.out.println ("Enter the description of this number"); description2 = In.getString (); System.out.println ("Enter the third contact number"); contactNum3 = In.getString (); System.out.println ("Enter the description of this number"); description3 = In.getString (); System.out.println ("Enter any comments on this contact"); comment = In.getString (); System.out.println ("Enter this contact's credit"); credit = In.getDouble (); System.out.println ("Enter this contact's account balance"); accountBalance = In.getDouble (); Contact_Temp temp = new Contact_Temp (name, idennum, address, businessType, email, contactNum1, description1, contactNum2, description2, contactNum3, description3, comment, credit, accountBalance); contactList.addContact (temp); } //it will go to directory and add contact else if (option == 2) //deletes contact { //gets contacts ID System.out.println ("Please Enter The Contact's Id: "); String Contact_number = In.getString (); temp = null; temp = contactList.findContactByIdennum (idennum); // If the contact exists if (temp != null) { contactList.deleteContact (temp); } // Else print error message else { System.out.println ("The account does not exist."); } } //Displays contact by ID else if (option == 3) { //gets contacts ID System.out.println ("Please Enter The Contact's Id: "); String Contact_number = In.getString (); temp = null; temp = contactList.findContactByIdennum (idennum); // If the contact exists if (temp != null) { temp.printContact(); } // Else print error message else { System.out.println ("The account does not exist."); } } //searches for contacts by name else if (option == 4) // System.out.println(temp.getName()); //shows all contacts else if (option == 5) contactList.printAllContacts (); //Shows contacts by Business Type else if (option == 6) { System.out.println ("Choose one of the following business types"); System.out.println ("Education\n shipping\n supplier\n buyer\n broker\n Airline Agency\n Financial Services\n Other\n"); businessType = In.getString (); System.out.println ("Printing contacts... "); for (int i = 0 ; i < 99 ; i++) { if ((contactList [i].getBusinessType ()).equals (businessType)) { index = i; break; } System.out.println (index); //how does it break out of loop? it finished at 99? } } //Shows contacts by Name and Display else if (option == 7) { contactList.sortContactsByAlphabeticalOrder(); System.out.println ("Printing all contacts in alphabetical order"); contactList.printAllContacts(); } //sorts contacts by business type else if (option == 8) { System.out.println(""); } //adds balance to contact else if (option == 9) { System.out.println ("Please Enter The Contact's Id: "); String Contact_number = In.getString (); temp = null; temp = contactList.findContactByIdennum (Contact_number); // If the contact exists if (temp != null) { //gets the balance and prints it. double accountBalance = temp.setAccountBalance (); accountBalance = In.getDouble(); System.out.println ("The balance is: $" + accountBalance); } // Else print error message else { System.out.println ("The account does not exist."); } } //Adds credit to contact else if (option == 10) { System.out.println ("Please Enter The Contact's Id: "); String Contact_number = In.getString (); temp = null; temp = contactList.findContactByIdennum (Contact_number); // If the contact exists if (temp != null) { //gets the credit and prints it. double credit = temp.setCredit (); credit = In.getDouble(); System.out.println ("The credit is: $" + credit); } // Else print error message else { System.out.println ("The account does not exist."); } } // Print Account Balance else if (option == 11) { System.out.println ("Please Enter The Contact's Id: "); String Contact_number = In.getString (); temp = null; temp = contactList.findContactByIdennum (Contact_number); // If the contact exists if (temp != null) { // Gets the balance and prints it. double balance = temp.getAccountBalance (); System.out.println ("The Balance is: $" + accountBalance); } // Else print error message else { System.out.println ("The account does not exist."); } } //adds credit else if (option == 12) { System.out.println ("Please Enter The Contact's Id: "); String Contact_number = In.getString (); temp = null; temp = contactList.findContactByIdennum (Contact_number); // If the contact exists if (temp != null) { //gets the credit and prints it. double credit = temp.getCredit (); credit = In.getDouble(); System.out.println ("The credit is: $" + credit); } // Else print error message else { System.out.println ("The account does not exist."); } } System.out.println ("Press any key to continue..."); } } }