Question
For this project, well create an abstract Publication class as the generic base class or parent of two specialized, more specific derived or child classes,
For this project, well create an abstract Publication class as the generic base class or parent of two specialized, more specific derived or child classes, Book and Periodical. Publication will define the attributes and their related setter and getter methods common to any type of publication:
- Title
- Publisher
- Publication Date
- Subject
We dont publish and read publications. We publish and read books and periodicals. They are more tangible, concrete entities, as opposed to publications which are somewhat vague and meaningless. Publication is a concept that has no reason to exist other than to serve as the general category to which books and periodicals belong. Therefore, we wouldnt create instances of it. Java enables us to prevent such classes from being instantiated by marking them as abstract, as in public abstract class Publication
Book will extend Publication and add some additional specialized attributes and their related setter and getter methods:
- ISBN
- Library of Congress number
- Author
- Number of pages
Periodical will extend Publication and add some additional specialized attributes and their related setter and getter methods:
- Publication frequency (daily, weekly, bi-weekly, monthly, quarterly, etc.)
- Editor
In addition to the setter and getter methods for their attributes, all of the classes will have a toString method and, for the sake of brevity, one constructor that accepts parameters for all their attributes. The toString methods of the derived classes will invoke the toString method of the base class to display values for the base class attributes they inherit.
The driver program will instantiate 3 objects of the Book class and 3 of the Periodical class then add all of them to an ArrayList of the Publication class. Next the driver will pass the ArrayList to a method that uses the Java for each or enhanced for loop statement to iterate through the ArrayList and invoke the toString method of each object it encounters. When a Book object is encountered, it should invoke the Book toString() method. When a Periodical object is encountered, it should invoke the Periodical toString() method.
Provide your Java source code for the Publication, Book and Periodical classes and the driver program.
I need 3 classes and a driver class.
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