public class Book { private String title; private String author; private int copyrightYear; private int available; public Book(String title, String author, int year) { this.title = title; this.author = author; this.copyrightYear = year; this.available = 2; //two copies of the same book } public String getTitle() { return title; } public String getAuthor() { return author; } public int getYear() { return copyrightYear; } public boolean equals(Book book) { if (book.getTitle().equals(this.getTitle()) && book.getAuthor().equals(this.getAuthor()) && book.getYear() == this.getYear()) { 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) { Book testBook1 = new Book("T1", "A", 2001); Book testBook2 = new Book("T2", "A", 2001); if (testBook1.equals(testBook2)) { System.out.println("Error: Equal"); } else { System.out.println("Correct: Unequal"); } testBook1.checkOut(); if (testBook1.getAvailable()) { System.out.println("Error: Available"); } else { System.out.println("Correct: Not available"); } } }