// // *************************************************************************** // // GROUP PROJECT Java Programming I Section 0663 // // MEMBERS: Phil Porvaznik PhilVaz@aol.com -- Initial design/Final Report // Mark Lundemann zoot@tampabay.rr.com -- Package Design // Tracey Morgan TMorgan72000@yahoo.com -- Testing and Driver // Swee-Boon Wong Sweeboon23@yahoo.com -- Testing and Driver // // *************************************************************************** // // ADDRESS BOOK Chapter 7, page 336, Problem # 1 // // DRIVER JAVA SOURCE CODE // // *************************************************************************** // // // Import the Address Book Package // import addressbook.*; import java.*; public class driver { static AddressBook testBook, secondBook, differentBook1, differentBook2, differentBook3; public static void main(String[] arg) { // // Heading1 for Test Results // System.out.println("Test results for Package addressbook"); System.out.println(); // // Heading2 for Test Results // System.out.println("Class " + "Method " + "Test# " + "Expected Output " + "Observed Output"); System.out.println("--------------------------------------------"+ "------------------------------------"); // // Constructor Test // testBook = new AddressBook("Jane", "Ann", "Smith", "1234 Bar Lane Tampa FL", "234-456-5678", "586 Berwin Blvd Tampa FL", "234-678-5436", "234-666-8769", "234-528-4763", "234-528-2154"); if (testBook.knowFirstName().equals("Jane") && testBook.knowMiddleName().equals("Ann") && testBook.knowLastName().equals("Smith") && testBook.knowHomeAddress().equals("1234 Bar Lane Tampa FL") && testBook.knowHomePhone().equals("234-456-5678") && testBook.knowBusinessAddress().equals("586 Berwin Blvd Tampa FL") && testBook.knowBusinessPhone().equals("234-678-5436") && testBook.knowFaxNumber().equals("234-666-8769") && testBook.knowCellNumber().equals("234-528-4763") && testBook.knowPagerNumber().equals("234-528-2154") ) // // If Fields equal then Output Header // { System.out.println("AddressBook " + "AddressBook " + " 1 " + "10 Field Entries " + "10 Field Entries"); } // // If Fields not equal then we have a Mismatch Error // else { System.out.println("Mismatch on Field/s\n"); } // // Observer Test // System.out.println("AddressBook " + "knowFirstName " + " 1 " + "Jane " + testBook.knowFirstName()); System.out.println("AddressBook " + "knowMiddleName " + " 1 " + "Ann " + testBook.knowMiddleName()); System.out.println("AddressBook " + "knowLastName " + " 1 " + "Smith " + testBook.knowLastName()); System.out.println("AddressBook " + "knowHomeAddress " + " 1 " + "1234 Bar Lane Tampa FL " + testBook.knowHomeAddress()); System.out.println("AddressBook " + "knowHomePhone " + " 1 " + "234-456-5678 " + testBook.knowHomePhone()); System.out.println("AddressBook " + "knowBusinessAddress" + " 1 " + "586 Berwin Blvd Tampa FL " + testBook.knowBusinessAddress()); System.out.println("AddressBook " + "knowBusinessPhone " + " 1 " + "234-678-5436 " + testBook.knowBusinessPhone()); System.out.println("AddressBook " + "knowFaxNumber " + " 1 " + "234-666-8769 " + testBook.knowFaxNumber()); System.out.println("AddressBook " + "knowCellNumber " + " 1 " + "234-528-4763 " + testBook.knowCellNumber()); System.out.println("AddressBook " + "knowPagerNumber " + " 1 " + "234-528-2154 " + testBook.knowPagerNumber()); System.out.println("AddressBook " + "firstMidLast " + " 1 " + "Jane Ann Smith " + testBook.firstMidLast()); System.out.println("AddressBook " + "lastFirstMid " + " 1 " + "Smith, Jane Ann " + testBook.lastFirstMid()); System.out.println("AddressBook " + "lastFirstMid " + " 1 " + "Smith, Jane Ann " + testBook.lastFirstMid()); // // Heading2 for Test Results // System.out.println("\n\nClass " + "Method " + "Test# " + "Expected Output " + "Observed Output"); System.out.println("--------------------------------------------"+ "------------------------------------"); // // Create second object with the same values as testBook // secondBook = new AddressBook("Jane", "Ann", "Smith", "1234 Bar Lane Tampa FL", "234-456-5678", "586 Berwin Blvd Tampa FL", "234-678-5436", "234-666-8769", "234-528-4763", "234-528-2154"); // // Equality Test using second object with the same first, middle, and last // System.out.println("AddressBook " + "equals " + " 1 " + "true " + testBook.equals(secondBook)); // // Inequality Test using an object with the same first, and different middle and last name // differentBook1 = new AddressBook("Jane", "Anne", "Smitt", "1234 Bar Lane Tampa FL", "234-456-5678", "586 Berwin Blvd Tampa FL", "234-678-5436", "234-666-8769", "234-528-4763", "234-528-2154"); System.out.println("AddressBook " + "equals " + " 2 " + "false " + testBook.equals(differentBook1)); // // Inequality Test using an object with the same first, middle, and different last name // differentBook2 = new AddressBook("Jane", "Ann", "Smitt", "1234 Bar Lane Tampa FL", "234-456-5678", "586 Berwin Blvd Tampa FL", "234-678-5436", "234-666-8769", "234-528-4763", "234-528-2154"); System.out.println("AddressBook " + "equals " + " 3 " + "false " + testBook.equals(differentBook2)); // // Inequality Test using an object with the different first, middle, lst name // differentBook3 = new AddressBook("Janet", "Anne", "Adams", "1234 Bar Lane Tampa FL", "234-456-5678", "586 Berwin Blvd Tampa FL", "234-678-5436", "234-666-8769", "234-528-4763", "234-528-2154"); System.out.println("AddressBook " + "equals " + " 4 " + "false " + testBook.equals(differentBook3)); // // Equality test using compareTo method. // Comparison is made using a second object with same values of the test object // System.out.println("AddressBook " + "compareTo " + " 1 " + "0 " + testBook.compareTo(secondBook)); // // Greater than test // Comparison is made using a second object with same values of the test object // System.out.println("AddressBook " + "compareTo " + " 2 " + "Greater Than Test " + testBook.compareTo(differentBook3)); // // Less than test // Comparison is made using a second object with same values of the test object // System.out.println("AddressBook " + "compareTo " + " 3 " + "Less Than Test " + testBook.compareTo(differentBook1)); } // end main } // end class driver