Question: Write a class Book to model books. This book object will have two instance variables: a title (String) and authors (Array of Strings). Write a

 Write a class "Book" to model books. This book object will

Write a class "Book" to model books. This book object will have two instance variables: a title (String) and authors (Array of Strings). Write a default constructor which sets title to "Test" and authors to mall, write a constructor receiving values for these fields. Lastly, implement getter and setter methods for your instance variables. In "Book", write a method "book ToString", which returns a string with the books information (in the format below. Use " to have a quote character in a string "The Lord of the Rings" by J.R.R. Tolkien "Nixonland" by Rick Perlstein "Berenstain Bears" by Stan Berenstain & Jan Berenstain Write a class "Bookshelf" to model a bookshelf. This bookshelf object will have two instance variables: a size (int) and books (ArrayList of Books). Write a defuult constructor which sets the size to two and initializes the ArrayList. Write a constructor which receives a single parameter for size and initializes the ArrayList. Write a getter method for the size instance variable. (Don't write a setter method, you can't change the size of a bookshelf after it's beer created!) Write a getter method for the books instance variable the bookshelf: a public void the shelf variable if there is room in the shelf, a public void method Rather than a single setter method, write three specific methods to modify the contents of method addBook which takes a single book parameter and adds it to eBook which takes no and removes the first book on the shelf (the book at position 0 in the books ArrayList), and a public void method emptyBookshelf which takes no parameters and rem all of the books from the shelf (empties the books ArrayList). Neither the "Book" class or the "Bookshelf" class can have a main method. If you want to test your "Book" and "Bookshelf classes, you may make a separate class with a main method. You do not need to submit this separate class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!