Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Design and implement an inheritance hierarchy to model different library items, including books, magazines, journals, videos, and electronic media such as CDs . Your design
Design and implement an inheritance hierarchy to model different library items, including
books, magazines, journals, videos, and electronic media such as CDs Your design should
encapsulate the common attributes and behaviors in a superclass and extend it with subclasses
that represent specific types of library items.
Superclass LibraryItem:
Fields:
uniqueID: A unique identification number for each library item.
title: The title of the item.
authorpublisher: Depending on the item, this could be the author for books or
publisher for magazines and journals
yearPublished: The year the item was published.
Methods:
displayInfo: Prints the common information about the item.
Appropriate getter and setter methods.
Subclasses: Design the following three subclasses from the following options, each with its
specific fields and methods:
Book:
Specific fields: genre, pageCount
Specific methods: Include methods relevant to a book, such as readPageint
pageNumber
Video:
Specific fields: runtimeLength in minutes director
Specific methods: Include methods relevant to videos, such as play or
displayRuntime
CD:
Specific fields: genre, artist, trackCount
Specific methods: Include methods relevant to CDs such as playTrackint trackNumber
or displayArtistInfo
Demonstration:
Create a main program that demonstrates the use of your classes. Instantiate objects of each
subclass and demonstrate setting their fields and calling their methods.
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