Related questions
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 nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
- Úploaded the image of the question, Kiindly help.arrow_forwardObjective: At the end of the activity, the students should be able to: Create a program that exhibits inheritance and Software Requirements: Latest version of NetBeans IDE Java Development Kit (JDK) 8 Procedure: Create four (4) Java classes. Name them RunEmployee, Employee, FullTimeEmployee, PartTimeEmployee. The RunEmployee class shall contain the main method and will be used to execute the Write a simple payroll program that will display employee’s information. Refer to the UML Class Diagram for the names of the variable and method. This should be the sequence of the program upon execution: Ask the user to input the name of the Prompt the user to select between full time and part time by pressing either F (full time) or P (part time). If F is pressed, ask the user to type his monthly salary. Then, display his name and monthly salary. If P is pressed, ask the user to type his rate (pay) per hour and the number of hours he worked for the entire month separated by...arrow_forwardJAVA Instructions Create a program with a class called Card that represents a standard playing card. Each card has a suit and a face value. Create a driver class called DealCards that deals five random cards. Helpful Tip: In the Card class you can use a switch or two Ace = 1Two=2 Three =3 ...Jack=11Queen =12King=13 Clubs: =1 Diamonds =2Hearts =3Spades =4 Face= 13Suits = 4arrow_forward
- Internally your program should have two Java classes: ValidatorNumeric (superclass) ValidatorString (subclass) The subclass ValidatorString extends ValidatorNumeric class, forming a hierarchy of two classes. Add a separate main class with the main() method to test all public methods in both ValidatorNumeric and ValidatorString classes. The main() method should create the necessary objects and run the user interaction as shown above. The ValidatorNumeric class is responsible for capturing user prompt and a range of valid numeric inputs. Its methods display the prompt and accept input from the user. It should provide the following public interface: // Default constructor ValidatorNumeric() // Specific constructor taking params as follows: ValidatorNumeric( String prompt, int min, int max ) // Another specific constructor taking params as follows: ValidatorNumeric( String prompt, double min, double max ) // Method that shows user prompt and gets an int from the user: public...arrow_forwardCreate a Class Pet with the following data members Identification: String species : String (e.g. cat, dog, fish etc) breed: String Age (in days): int Weight: float Dead: boolean 1. Provide a constructor with parameters for all instance variables. 2. Provide getters for all and setters for only breed, and weight 3. Provide a method growOld() that increases the age of the pet by one day. A dead pet wont grow old 4. Provide a method growHealthy(float w) that increases the weight of the pet by the given amount w. A dead pet cannot grow healthy. 5. Provide a method fallSick(float w) that reduces the weight of the pet by the given amount. The least weight a pet can have is 0 which will mean that the pet has died. If the value of weigh is 10 kg and the method is called with an argument of 11 kg then you will set it to 0 and set the dead to an appropriate value to mark the death of the pet 6. Provide a toString method that shows an appropriate well formatted string...arrow_forwardNeed it in the java language, doesn't have to be perfect. If you can do the whole program that would be best but if not an outline would suffice so I can get a good idea of how to finish the program. Thanks!arrow_forward
- Use Java Programming Language Create a Loan Account Hierarchy consisting of the following classes: LoanAccount, CarLoan, PrimaryMortgage , UnsecuredLoan, and Address. Each class should be in it's own .java file. The LoanAccount class consists of the following properties: principal- the original amount of the loan. annualInterestRate - the annual interest rate for the loan. It is not static as each loan can have it's own interest rate. months - the number of months in the term of the loan, i.e. the length of the loan. and the following methods: a constructor that takes the three properties as parameters. calculateMonthlyPayment() - takes no parameters and calculates the monthly payment using the same formula as Assignment 1. getters for the three property variables. toString() - displays the information about the principle, annualInterestRate, and months as shown in the example output below. The CarLoan class which is a subclass of the LoanAccount class and consists of the...arrow_forwardPick the incorrect statement: O A class can implement more than one interface O A class can extend more than one classes O An interface can extend more than one interfaces O An interface cannot extend a classarrow_forwardJava Program This assignment requires one project with two classes. Class Employee Class Employee- I will attach the code for this: //Import the required packages. import java.text.DecimalFormat; import java.text.NumberFormat; //Define the employee class. class Employee { //Define the data members. private String id, lastName, firstName; private int salary; //Create the constructor. public Employee(String id, String lastName, String firstName, int salary) { this.id = id; this.lastName = lastName; this.firstName = firstName; this.salary = salary; } //Define the getter methods. public String getId() { return id; } public String getLastName() { return lastName; } public String getFirstName() { return firstName; } public int getSalary() { return salary; } //Define the method to return the employee details. @Override public String toString() { //Use number format and decimal format //to...arrow_forward
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education