Loading...
Loading...
Loading...
A library stores n books, each with an ISBN and a one-word title. Two books are the same book when their ISBNs match. Write Book with equals() and hashCode() by ISBN and a toString() that returns the title. For each query ISBN, make a new Book with that ISBN, search the shelf with equals() and print the title, or NOT FOUND.
isbn title. The next line has q, then q lines with one ISBN each.NOT FOUND.Example
Input
3 978-81 WingsOfFire 978-01 TheGuide 978-55 Godaan 3 978-01 978-99 978-81
Output
TheGuide NOT FOUND WingsOfFire
The new Book("978-01", "") is a different object but equal by ISBN.
Try the problem first. Open one hint at a time.
The query object is new, so == never finds it. Search with shelf[i].equals(wanted).
The ISBN is a String: compare it with equals(), not ==.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor