class Book { String title; String author; int numPages; boolean isCopyrighted; Book( String _title, String _author, int _numPages, boolean _isCopyrighted ) { this.title = _title; this.author = _author; this.numPages = _numPages; this.isCopyrighted = _isCopyrighted; } // ( template for book-handling functions // ... funcForBook( /* Book this */ ) { // ... this.author // ... this.title // ... this.numPages // ... this.isCopyrighted // } // double readingTime( /* Book this */ ) { return 2 * this.numPages; } @Override public String toString( /* Book this */ ) { return this.author + ", by " + this.title + this.numPages + (this.isCopyrighted ? "©" : "" ); } void tests() { Book b0, b1; b1 = new Book( "The Cat in the Hat", "Seuss", 37, true ); b0 = new Book( "Soul and Wit", "Barland", 0, false ); //b0.title; //b1.isCopyrighted; assert (new Book( "The Cat in the Hat", "Seuss", 37, true )).readingTime() == 74; assert b0.readingTime() == 0; /* assert (new Book( "The Cat in the Hat", "Seuss", 37, true )).toString() .equals( "The Cat in the Hat, by Seuss (37pp), ©" ); assert b0.toString().equals( "Soul and Wit, by Barland (0pp)" ); */ } Book funcForBook( /* Book this */ String newAuthor, int addedPages ) { return new Book( this.author + newAuthor, "Son of " + this.title, this.numPages + newPages, false ); } }