Answered step by step
Verified Expert Solution
Link Copied!

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.
author/publisher: 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 readPage(int
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 playTrack(int 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions