Question: In Java please. You are tasked with developing a Library Management System. The system should manage different types of library items: Books, Magazines, and DVDs
In Java please.
You are tasked with developing a Library Management System. The system should manage different types of library items: Books, Magazines, and DVDs Each type of item will implement specific rules for calculating late fees, and you will integrate an interface to enforce that all library items can calculate late fees and display details.
Requirements
Create an Interface: ILibraryItem
Methods:
void displayDetails: Print the details of the library item. double calculateLateFeeint daysLate: Calculate the late fee for the item.
Create a Base Class: LibraryItem
Implements: The ILibraryItem interface.
Fields:
String title: The title of the item. String author: The author or publisher for magazinesDVDs of the item.
Constructor:
Initialize the fields title and author.
Methods:
Implement the displayDetails method to print the title and author of the item. Leave the calculateLateFee method abstract to enforce implementation by subclasses.
Create Subclasses
Book
Implements: Inherits from LibraryItem and implements calculateLateFee based on the rule:
Late Fee Rule: $ per day late.
Override the calculateLateFee method to implement this rule.
Magazine
Implements: Inherits from LibraryItem and implements calculateLateFee based on the rule:
Late Fee Rule: $ per day late.
Override the calculateLateFee method to implement this rule.
DVD
Implements: Inherits from LibraryItem and implements calculateLateFee based on the rule:
Late Fee Rule: $ per day late.
Override the calculateLateFee method to implement this rule.
Demonstrate Polymorphism in the main Method
Create an array of type ILibraryItem and populate it with:
One Book object. One Magazine object. One DVD object.
Use a loop to:
Call displayDetails for each item. Call calculateLateFee for each item with a value of days late and print the fee.
Sample output:
Title: The Great Gatsby
Author: F Scott Fitzgerald
Late Fee for days: $
Title: Time Magazine
Author: Time Publishers
Late Fee for days: $
Title: Inception
Author: Christopher Nolan
Late Fee for days: $
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
