Question: Java Help: Create a class called Book . This class will have private fields for the following details: storecode, price and genre. When you call

Java Help: Create a class called Book. This class will have private fields for the following details: storecode, price and genre. When you call the constructor of this class, it should create a new instance of the Book class that has randomly generated values for the details mentioned.

Storecodes will be stored specifically as strings and have a format like the following 11-B-4946. Prices can be rounded to the nearest dollar and the generated values should be between $10 and $200. Genres (e.g. horror, fantasy etc) will also be stored as strings and should be chosen randomly from one of a finite list of options (hint: create a static final array listing the genres, then select one at random for each new Book object that is created). It is recommended to override the toString() method, so that the details of a Book may be printed to the console as per the sample code below: // create a new Book object with a randomly chosen storecode, genre and price Book b = new Book(); // prints e.g. horror book with storecode 08-D-6214 worth 112 System.out.println(b.toString()); Then create a class called BookStore. This class will have a private field that specifies its capacity of books e.g. 200 or 300 books. It will also have a private field that holds a list of books using an ArrayList. BookStore should have a method isEmpty() that returns a boolean indicating whether the bookstore is currently empty, and a method isFull() that returns a boolean indicating whether the bookstore is currently full. BookStore should also have an addBook() method to add a new Book to the list, and a takeBook() method to remove the first (oldest) Book in the list and return it to the caller. You should assume that a Customer will always buy the first available Book in the ArrayList.

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!