, this is a java programming question, I'll attach the image and type the question Implement the class diagram below (diagram attached)
Hi, this is a java programming question, I'll attach the image and type the question
Implement the class diagram below
(diagram attached)
Create a new class called LibraryManagementService and implement the main method. Inside the main
method:
• Create the following book objects.
o Title: Sherlock Homes
o Author: Arthur Conan Doyle
o Genre: Detective fiction
o Title: Pride and Prejudice
o Author: Jane Austen
o Genre: Fiction
o Title: Anne of Green Gables
o Author: Jane Eyre
o Genre: Drama
o Title: Leave it to PSmith
o Author: P G Wodehouse
o Genre: Comedy
o Title: Angels and Demons
o Author: Dan Brown
o Genre: Suspense
• All titles are case insensitive (Sherlock Homes and SHERLOCK HOMES should refer to the same
book)
• By default, for all the books, isAvailable should be true
• Implement the following methods in the Library class:
o addBook() should take in a book object and should add it to the books array. For
instance, if we create a 6th book object
• Title: Jurassic Park
• Author: Michael Crichton
• Genre: Science fiction
▪ the method should return true, and you should print “Book successfully added
to the library”
▪ getBooks() should return all the 6 books objects.
▪ If a title already exists, it should return false, and you should print “Book Already
exists in the library.”
o borrowBook() should take in the title of the book as an argument
▪ If the book is not found, you should return false from the method and print
“Sorry! The title not found in the library”
▪ If the title is found
• if the title is available(isAvailable = true)
o isAvailable should be set to false for that book
o You should return true from the method and print “You have
successfully borrowed the book”
• If the title is not available, you should return false from the method and
print “Sorry!! The title is currently not available for borrowing”
o returnBook() should take in the title of the book as an argument
▪ If the book is not found, you should return false from the method and print
“Sorry! The title not found in the library”
▪ If the title is found
• if the title is not available(isAvailable = false)
o isAvailable should be set to true for that book
o You should return true from the method and print “You have
successfully returned the book”
• If the title was not borrowed, you should return false from the method
and print “The title is currently not available for borrowing”
▪ Perform the following actions:
o Create an object for the Library class with the following values:
▪ Name: Greenville Public Library
▪ Address: Main Street
▪ City: Greenville
▪ Books: Set it to 5 book objects created earlier
o Add the 6th book:
• Title: Jurassic Park
• Author: Michael Crichton
• Genre: Science fiction
o Try to return the book titled “Leave it to PSmith”
o Try to borrow the book titled “Summer Moonshine”
o Try to borrow the book titled “Leave it to PSMITH”
o Try to return the book titled “Leave it to Psmith”
o Add the book
▪ Title: Jurassic Park
▪ Author: Michael Crichton
▪ Genre: Science fiction
o Add the book
▪ Title: Matilda
▪ Author: Roald Dahl
▪ Genre: Fantasy fiction
o Borrow the book titled “Jurassic Park”
o Borrow the book titled “Sherlock Holmes”
o Print only the available books (isAvailable = true) in the library in the following format:
▪ Title:
▪ Author:
▪ Genre
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images