Test that Occurred Due to Some Idiot Triggering Mr. M
idk man ;-;
Close Book Part of Test:
- Define 1 Argument constructor for title
- Define toString method for title, and a tester method
- Generate unique id for class
- Create a public getter that has Book Count
- Define tester method that initializes at least 2 books, outputs title, and provides a count of books in library.
import java.util.UUID; //built in Java method that allows user to generate a Universally Unique Identifier --> guarantees each ID is unique
public class Book {
    private final String id;
    private final String title;
    private static int bookCount;
    //initializing two instance variables...ID and title
    public Book(String title) {
        this.id = UUID.randomUUID().toString(); //Telling id to be a randomly generated UUID
        this.title = title; 
        bookCount++; //adding to bookCount
    }
    //Getters for id, title, and bookCount
    public String getId() {
        return id;
    }
    public String getTitle() {
        return title;
    }
    public static int getBookCount() {
        return bookCount;
    }
    @Override
    //toString method
    public String toString() {
        return "Book{" +
                "id='" + id + '\'' +
                ", title='" + title + '\'' +
                '}';
    }
    public static void main(String[] args) {
        Book book1 = new Book("The Great Gatsby");
        Book book2 = new Book("To Kill a Mockingbird");
        System.out.println(book1);
        System.out.println(book2);
        System.out.println("Number of books in library: " + Book.getBookCount());
    }
}
Book.main(null);
Open Book Part of the Exam
- Ensure Novel and Textbook run the Constructor from Book
- Create instance variables unique to Novel has Author, Textbook has publishing company. These are not required in Constructor. Make sure there are getters and setters.
- Define a default method in Book that returns shelfLife from date/time of constructor. Define shelfLife methods as method in TextBook and Novel. A Textbook has a fixed shelf life based on the date/time constructor. A Novel has a computed shelf life and is validated by averaging a certain number of Checkouts average over shelf life, use sensible data structure.
- Make a method to count time book is checked out
- Make a method to determine if book should come off of the shelf
- Define tester method to test items #1-#5