public class Book { private String title; private String author; private int copyrightYear; private int available; private Size size; public Book(String title, String author, int year, Size sz) { this.title = title; this.author = author; this.copyrightYear = year; this.available = 2; //two copies of the same book this.size = sz; } public String getTitle() { return title; } public String getAuthor() { return author; } public int getYear() { return copyrightYear; } public Size getSize() { return size; } public boolean equals(Book book) { if (book.getTitle().equals(this.getTitle()) && book.getAuthor().equals(this.getAuthor()) && book.getYear() == this.getYear() && book.getSize().equals(this.getSize())) { return true; } else { return false; } } public boolean getAvailable() { if (available > 0) { return true; } else { return false; } } public void checkOut() { if (available > 0) { available--; } else { System.out.println("Error: Tried to check out an unavailable book."); } } public void checkIn() { if (available > 1) { System.out.println("Error: Tried to check in an available book."); } else { available++; } } public static void main(String[] args) { Size sz1 = new Size(); //default constructor height=11, width=8.5 Size sz2 = new Size(11, 8.5); Book testBook1 = new Book("T1", "A", 2001, sz1); Book testBook2 = new Book("T1", "A", 2001, sz2); if (testBook1.equals(testBook2)) { System.out.println("Equal books"); } else { System.out.println("Unequal books"); } testBook1.checkOut(); if (testBook1.getAvailable()) { System.out.println("One copy of the book Available"); } else { System.out.println("Book not available any more"); } testBook1.checkOut(); if (testBook1.getAvailable()) { System.out.println("Error: All copies of the book were checked out but still available"); } else { System.out.println("Correct: no copy of the book is available any more"); } } }