Question
JAVA 1. Create a base class called Book. It should keep track of the following data items (you need to decide on the data type
JAVA
1. Create a base class called Book. It should keep track of the following data items (you need to decide on the data type for each data item):
- Title
- Author
- Publication Year
- Number of pages
- Medium (0 - printed hardcover, 1- printed softcover, 2- electronic, 3 - all)
- Number of copies printed
- Production cost (i.e. the sum of all production expenses such as licensing, royalties, printing cost, etc.)
- Sale price (i.e. what does the book sell for, e.g. $7.95/copy)
- Number of copies sold
- Number of positive reviews
- Number of negative reviews
The class should have appropriate constructors, getters, setters, and a PrintInfo() method.
2. Create a class Textbook, derived from Book. The class inherits everything from the parent class and adds the following data (and appropriate methods):
- Field (e.g. Computer Science, Biology, etc.)
- Topic (e.g. Computer Architecture, Molecular Modeling, etc.)
3. Create a class Novel, derived from Book. The class inherits everything from the parent class and adds the following data (and appropriate methods):
- Genre (i.e. Sci-fi, Thriller, etc.)
4. Create an interface called PublicationInfo, which declares methods:
- CostEffective(): This method, when implemented in a class should return true if the book is cost-effective, i.e. if the funds received from the sale of the book exceeds the production expenses. Otherwise return false.
- GeneratesInterest(): The method, when implemented in a class, should return true if the number of positive reviews exceeds the number of negative review and if the number of sales exceeds a certain threshold (for example, when implemented in the Textbook class, the threshold 80% of the copies printed, whereas for novels, the threshold should be set to a larger number, say 65% of the copies printed). Both class Textbook and Novel should implement the methods of the PublicationInfo interface.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started