/** * Represents bibliographic information for books. */ public class Book implements Publication { private final String title, author, publisher, location; private final int year; private final TypeOfBook type; /** * Constructs a {@code Book} object. * * @param title the title of the book * @param author the author of the book * @param type the type of the book * @param publisher the publisher of the book * @param location the location of the publisher * @param year the year of publication */ public Book(String title, String author, TypeOfBook type, String publisher, String location, int year) throws IllegalArgumentException { if (year < 0) { throw new IllegalArgumentException("Year of publication cannot be a " + "negative number"); } this.title = title; this.author = author; this.type = type; this.publisher = publisher; this.location = location; this.year = year; } @Override public String citeApa() { return author + " (" + year + "). " + title + ". " + location + ": " + publisher + "."; } @Override public String citeMla() { return author + ". " + title + ". " + location + ": " + publisher + ", " + year + "."; } }