// Name : Matthew Reeves // This is a program to create a book entry for an unsorted list //creates the Book class public class Book { //creates instance variables for Book class private String Title; private String Author; private String Publisher; private int PubYear; private String ISBN; //constructor for individual parameters passed to class set attributes //for Book object public Book(String t, String a, String p, int py, String i) { setBook(t, a, p, py, i); } //constructor for creating Book object when an existing Book //object is passed in as the parameter public Book(Book abook) { setBook(abook.Title, abook.Author, abook.Publisher, abook.PubYear, abook.ISBN); } //default constructor public Book() { } //actually assigns attributes to the book public boolean setBook(String t, String a, String p, int py, String i) { Title=t; Author=a; Publisher=p; PubYear=py; ISBN=i; //data validation for valid pubyear if (py<0) { PubYear=0; return false; } else { return true; } } //determines if two book objects have the same data values stored within them public boolean equals(Book abook) { if (Title.equals(abook.Title)) { if (Author.equals(abook.Author)) { if (Publisher.equals(abook.Publisher)) { if (PubYear==abook.PubYear) { if (ISBN.equals(abook.ISBN)) { return true; } } } } } return false; } //returns formatted string with info on the book in question public String toString() { return String.format("Title:\t\t\t %s\nAuthor:\t\t\t %s\nPublisher:\t\t %s\nPublication Year:\t %d\nISBN:\t\t\t %s\n",Title, Author, Publisher, PubYear, ISBN); } }