import tester.ISame; /** * This class represents a book in a bookstore with title, * author and the year of publication. */ class Book implements ISame{ /** the title of this book */ String title; /** the author of this book */ String author; /** the year this book was published */ int year; /** * The full constructor * @param title book title * @param author book author * @param year publication year */ Book(String title, String author, int year){ this.title = title; this.author = author; this.year = year; } /* TEMPLATE: FIELDS: ... this.title ... -- String ... this.author ... -- String ... this.year ... -- int METHODS FOR FIELDS: ... this.name.equals(String) ... -- boolean ... this.author.equals(String) ... -- boolean METHODS FOR THIS CLASS: ... this.same(Book) ... -- boolean */ /** * Is this book the same as the given one? * @param that the given book * @return true if the books are the same */ public boolean same(Book that){ return this.title.equals(that.title) && this.author.equals(that.author) && this.year == that.year; } }