/* * ========================================================================= * TestRelationship: Create a bi-directional relationship between a customer * and a book object. * * Written by: Mark Austin December 2011 * ========================================================================= */ public class TestRelationship { public static void main ( String args [] ) { // Create book and customer objects. Book book = new Book(); book.setName("The Cat in the Hat"); book.setAuthor("Dr Seuss"); Customer owner = new Customer(); owner.setName("Angela Austin"); // Create a bidirectional customer-book association. owner.setBook( book ); book.setCustomer( owner ); // Retrieve and print owner-book relationship. System.out.println ( "Retrieve and print owner-book relationship" ); System.out.println ( "==========================================" ); System.out.println ( owner.toString() ); // Retrieve and print book-owner relationship. System.out.println ( "Retrieve and print book-owner relationship" ); System.out.println ( "==========================================" ); System.out.println ( book.toString() ); } }