Skip to content

Commit 4a624fd

Browse files
committed
fix solution according to description and diagramm
1 parent f625ac7 commit 4a624fd

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

BookCollection.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ public void addBook(Author author, Book book) {
1818
collection.get(author).add(book);
1919
}
2020

21-
public Optional<Book> getBookByTitle(String title) {
21+
public Book getBookByTitle(String title) {
2222
for (List<Book> books : collection.values()) {
2323
for (Book b : books) {
2424
if (b.title().equals(title)) {
25-
return Optional.of(b);
25+
return b;
2626
}
2727
}
2828
}
29-
return Optional.empty();
29+
return null;
3030
}
3131

32-
public Optional<Author> getMostDiligentAuthor() {
32+
public Author getMostDiligentAuthor() {
3333
Author mostDiligentAuthor = null;
3434
int mostBooks = 0;
3535
for (Entry<Author, List<Book>> entry : collection.entrySet()) {
@@ -38,6 +38,6 @@ public Optional<Author> getMostDiligentAuthor() {
3838
mostBooks = entry.getValue().size();
3939
}
4040
}
41-
return Optional.ofNullable(mostDiligentAuthor);
41+
return mostDiligentAuthor;
4242
}
4343
}

DuplicateKeyException.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
public class DuplicateKeyException extends Exception {
2-
3-
private static final long serialVersionUID = 1L;
42
}

0 commit comments

Comments
 (0)