Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program to define a LibraryItem class, a BookType class as a subclass of the LibraryItem class, and a driver program. Some of

Write a Java program to define a LibraryItem class, a BookType class as a subclass of the LibraryItem class, and a driver program. Some of the characteristics of the LibraryItem class are barCodeNumber, publisher and publicationDate. This information is common to all library items including those in BookType subclass. The LibraryItem class should provide two interfaces--- a constructor and a print. The constructor method receives the values of barCodeNumber, publisher and publicationDate to be stored. The only access to the data must be through the print interface which simply outputs the barCodeNumber, publisher and publicationDate of the given library item object. Class BookType inherits from LibraryItem class with public inheritance. The BookType class includes its own data members (attributes): title, author, isbn and price. The BookType class also includes methods print, setPrice and getPrice. The BookType constructor must pass the values of barCodeNumber, publisher and publicationDate to the LibraryItem constructor so the superclass data members barCodeNumber, publisher and publicationDate can be initialized. It then initializes its own data members title, author, isbn and price. The methods setPrice and getPrice are declared in class BookType to set and get the price of the book. The BookType version of the print method must have the same prototype as the LibraryItems print --- this is an example of function overriding. The BookTypes print method must call the superclass version of the print method to output the inherited attributes stored at the superclass level. The BookType print method must also output its own attributes title, author, isbn and price. Your test driver program must instantiate some BookType objects, initialize them, and for each object, call the BookTypes print, setPrice and getPrice methods to display the objects data and/or to set and get the new price.

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_2

Step: 3

blur-text-image_3

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

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions

Question

3. Is there opportunity to improve current circumstances? How so?

Answered: 1 week ago