Question: a ) Create a class Book with the following instance variables: o Title: string o Author: string o Number Of Pages: int o Static variable
a Create a class Book with the following instance variables:
o Title: string
o Author: string
o Number Of Pages: int
o Static variable to track the total number of books created.
Include both default and arguments constructors.
Implement getters and setters for all instance variables.
Implement a method displayInfo to display book details and a static method getTotalBooks to show the total number of books.
In the main method, create book objects and display their information.
Modify some details using setters.
b Create a subclass Ebook that inherits from Book that has the following:
A new instance variable as file Size then
Overrideoverload the displayInfo method in Ebook to display the file size in addition.
Use an array of Book type, storing both Book and Ebook objects.
Handle invalid data eg negative file size by throwing a custom exception.
Sample Run:
c Extend the library system to manage multiple types of media Books Magazines, DVDs as follows:
Implement an interface Readable with a method void read
Create an abstract class Media with an abstract method void displayMediaInfo and a concrete method boolean isAvailable
Extend Media in classes Book, Magazine, and DVD where Book and Magazine implement Readable.
Use a D array to store media in the library as follows:
Media library new Media;
library book; book is created using Book constructor
library magazine; magazine is created using Magazine constructor
library dvd; dvd is created using DVD constructor
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
