Class Book (Part 1) Close Book

import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

public class Book {

    private static int bookCount; // defining the static integer that has the count of the books
    public String bookTitle; // defining the string that stores the title of the books
    private static long id; // defining the static variable that has the unique id, static so that it stays in the memory and shared with all the objects
    private LocalTime timeEntered;
    private static ArrayList<Book> library = new ArrayList<Book>();

    public Book(String bookTitle) { // 1 argument constructor that passes in the book title
        this.bookTitle = bookTitle; 
        bookCount++; // add to the book counter each time a Book object is created
    }

    public static int getCount(){ // public getter for the book count
        return bookCount;
    }
    
    public long nextId() { // unique ids using a counter for each book
        return id++;
    }
   
    public String toString() { // toString method defined with Id and Title
        return "Id: " + nextId() + " | Title: " + this.bookTitle + "  Time Entered: " + getTime(); 
    }

    public LocalTime getTime() {
        timeEntered = LocalTime.now();
        return timeEntered;
    }

    public void shelfLife() {
        
    }

    public static void main(String[] args) { // tester method defined 
        Book book1 = new Book("Harry Potter");
        Book book2 = new Book("The Great Gatsby");
        Book book3 = new Book("To Kill a Mockingbird");
        Book book4 = new Book("The Hunger Games");

        Book books[] = {book1, book2, book3, book4};

        System.out.println("Books in the Library: "); // array to print each book id and title
       
        for( Book book : books) {
            System.out.println(book);
        }

        System.out.println();
        System.out.println("Total Number of Books: "); // print for counter
        System.out.println(getCount());
    }
}
Book.main(null);
Books in the Library: 
Id: 0 | Title: Harry Potter  Time Entered: 22:39:57.374730656
Id: 1 | Title: The Great Gatsby  Time Entered: 22:39:57.426246004
Id: 2 | Title: To Kill a Mockingbird  Time Entered: 22:39:57.426461489
Id: 3 | Title: The Hunger Games  Time Entered: 22:39:57.426592390

Total Number of Books: 
4
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

public class Novel extends Book {
    
    private String author;
    private int year;
    private String genre;
    private LocalTime timeEntered;

    public Novel(String bookTitle, String author) {
        super(bookTitle);
        this.author = author;
    }
    

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String newAuthor) {
        this.author = newAuthor;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int newYear) {
        this.year = newYear;
    }

    public String getGenre() {
        return genre;
    }

    public void setGenre(String newGenre) {
        this.genre = newGenre;
    }

    public LocalTime getTime() {
        timeEntered = LocalTime.now();
        return timeEntered;
    }

    
    public String toString() { // toString method defined with Id and Title
        return "Id: " + nextId() + " | Title: " + this.bookTitle + "  Author: " + this.author + "  Genre: " + this.genre + "  Year: " + this.year + "  Time Entered: " + getTime(); 
    }
    
    public static void main(String[] args) { // tester method defined 
        Novel novel1 = new Novel("The Giver", "Lois Lowry");
        novel1.setYear(1993);
        Novel novel2 = new Novel("Of Mice and Men", "John Steinbeck");
        novel2.setYear(1993);
        Novel novel3 = new Novel("Romeo and Juliet", "William Shakespeare");
        novel3.setYear(1597);
        Novel novel4 = new Novel("The Catcher in the Rye", "J. D. Salinger");
        novel4.setYear(1951);

        Novel novels[] = {novel1, novel2, novel3, novel4};

        System.out.println("Novels in the Library: "); // array to print each book id and title
       
        for( Novel novel : novels) {
            novel.setGenre("Fiction");
            System.out.println(novel);            
        }

        System.out.println();
        System.out.println("Total Number of Books: "); // print for counter
        System.out.println(getCount());

        System.out.println();
        System.out.println("Testing Getters: ");
        System.out.println(novel2.getAuthor());
        System.out.println(novel1.getYear());
        System.out.println(novel2.getGenre());
        System.out.println(novel2.getTime());
    }
}
Novel.main(null);
Novels in the Library: 
Id: 4 | Title: The Giver  Author: Lois Lowry  Genre: Fiction  Year: 1993  Time Entered: 22:40:02.963316295
Id: 5 | Title: Of Mice and Men  Author: John Steinbeck  Genre: Fiction  Year: 1993  Time Entered: 22:40:02.964125573
Id: 6 | Title: Romeo and Juliet  Author: William Shakespeare  Genre: Fiction  Year: 1597  Time Entered: 22:40:02.964400496
Id: 7 | Title: The Catcher in the Rye  Author: J. D. Salinger  Genre: Fiction  Year: 1951  Time Entered: 22:40:02.964576679

Total Number of Books: 
8

Testing Getters: 
John Steinbeck
1993
Fiction
22:40:02.965392844

Open book

public class Textbook extends Book {

    private String publisher;
    private int year;
    private String level;

    public Textbook(String bookTitle, String publisher, String level) {
        super(bookTitle);
        this.publisher = publisher;
        this.level = level;
    }

    public String getPublisher() {
        return publisher;
    }
    
    public void setPublisher(String newPublish) {
        publisher = newPublish;
    }

    public int getYear() {
        return year;
    }
    
    public void setYear(int newYear) {
        this.year = newYear;
    }

    public String getLevel() {
        return level;
    }

    public void setLevel(String newLevel) {
        level = newLevel;
    }

    public String toString() { // toString method defined with Id and Title
        return "Id: " + nextId() + " | Title: " + this.bookTitle + "  Publisher: " + this.publisher + "  Level: " + this.level + "  Year: " + this.year + "  Time Entered: " + getTime(); 
    }

    public static void main(String[] args) { // tester method defined 
        Textbook text1 = new Textbook("U.S. History", "Publisher 1", "High School");
        text1.setYear(2001);
        Textbook text2 = new Textbook("World History", "Publisher 2", "Middle School");
        text2.setYear(2009);
        text2.setPublisher("Penguin Publisher");

        Textbook textbooks[] = {text1, text2};
        
        System.out.println("Textbooks in the Library: "); // array to print each book id and title
       
        for( Textbook textbook : textbooks) {
            System.out.println(textbook);            
        }

        System.out.println();
        System.out.println("Total Number of Books: "); // print for counter
        System.out.println(getCount());

        System.out.println();
        System.out.println("Testing Getters: ");
        System.out.println(text1.getLevel());
        System.out.println(text2.getPublisher());
    }
}
Textbook.main(null);
Textbooks in the Library: 
Id: 8 | Title: U.S. History  Publisher: Publisher 1  Level: High School  Year: 2001  Time Entered: 23:01:35.299100784
Id: 9 | Title: World History  Publisher: Penguin Publisher  Level: Middle School  Year: 2009  Time Entered: 23:01:35.303569806

Total Number of Books: 
10

Testing Getters: 
High School
Penguin Publisher

Simulation

1:15:22
public void drawLine(int n) {
    for (int i = 1; i <= n; i++) {
        System.out.print("*");
        drawLine(n - 1);
        n--;
    }
}
drawLine(10);
*****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************