/* * ====================================================================== * Customer.java: Create a Customer object with an association to a book. * ====================================================================== */ public class Customer { private String name; // Data attributes public Book book; // Association attributes // Constructors .... public Customer () { this.book = null; } // String representation ... public String toString() { String s = ""; if (this.book != null ) s += "Customer: " + getName() + " owns " + book.getName() + "\n"; else s += "Customer: " + getName() + " doesn't own a book \n"; return s; } // Attribute accessors public String getName() { return name; } public void setName(String name) { this.name = name; } // Association accessors public Book getBook() { return book; } public void setBook( Book book ) { if (book != null) this.book = book; } }