Question: Please help with the following Java Project. Also please include comments in the code as well. HW on Inheritance - The goal of this coding
Please help with the following Java Project. Also please include comments in the code as well.
HW on Inheritance
The goal of this coding exercise is to wite the code for two classes BookstoreBook and LibraryBook. Both classes have these fields:
author: String
tiltle: String
isbn : String
The BookstoreBook has an additional data member to store the price of the book, and whether the book is on sale or not. If a bookstore book
is on sale, we need to add the reduction percentage like off...etc For a LibraryBook, we add the call number that tells you where the
book is shelved in the library as a string. The call number is automatically generated by the following procedure:
The call number is a string with the format xxyyyc where xx is the floor number that is randomly assigned our library has
floors yyy are the first three letters of the authors name we assume that all names are at least three letters long and c is the last
character of the isbn.
In each of the classes, add the setters, the getters, at least three constructors of your choosing and override the toString method see sample
run below
Your code should display the list of all books keyed in by the user
Create an abstract class that you name Book. The class Book should have the fields and the code that is shared by both the BookstoreBook
and the LibraryBook classes. Both of those classes extend the Book class. Test your code with an array of elements of Book. Call that array
list You cant have an array to store the BookstoreBook objects and another one to store the LibraryBook objects. One array list to hold all
the book objects that your code creates
Create a class that you call BookList in which you put list as a private field. Your code must have the following structure:
public class Main
public static void mainString args
Instantiate the class BookList here
abstract class Book
code of the abstract class Book
You may add an abstract method if you see fit...
class BookstoreBook extends Book
fields and specific code to the BookstoreBook class goes here
class LibraryBook extends Book
fields and specific code to the LibraryBook class goes here
class BookList
private Book list;
public BookList
list new Book;
Additional code goes here if needed...
Sample Run
The users entry is marked in boldface
Welcome to the book program!
Would you like to create a book object? yesno: yEs
Please enter the author, title ad the isbn of the book separated by : Ericka JonesJava made Easy
Got it
Now, tell me if it is a bookstore book or a library book enter BB for bookstore book or LB for library book: BLB
Oops! Thats not a valid entry. Please try again: Bookstore
Oops! Thats not a valid entry. Please try again: bB
Got it
Please enter the list price of JAVA MADE EASY by ERICKA JONES:
Is it on sale? yn: y
Deduction percentage:
Got it
Here is your bookstore book information
JAVA MADE EASY by ERICKA JONES, $ listed for $
Would you like to create a book object? yesno: yeah
Im sorry but yeah isnt a valid answer. Please enter either yes or no: yes
Please enter the author, title and the isbn of the book separated by : Eric JonesJava made Difficult
Got it
Now, tell me if it is a bookstore book or a library book enter BB for bookstore book or LB for library book: LB
Got it
Here is your library book information
JAVA MADE DIFFICULT by ERIC JONESERI
Would you like to create a book object? yesno: yes
Please enter the author, title and the isbn of the book separated by : Erica JoneJava made too Difficult
Got it
Now, tell me if it is a bookstore book or a library book enter BB for bookstore book or LB for library book: LB
Got it
Here is your library book information
JAVA MADE TOO DIFFICULT by ERICA JONEERI
Would you like to create a book object? yesno: no
Sure!
Here are all your books...
Library Books
JAVA MADE DIFFICULT by ERIC JONESERI
JAVA MADE TOO DIFFICULT by ERICA JONEERI
Bookstore Books
JAVA MADE EASY by ERICKA JONES, $ listed for $
Take care now!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
