Skip to content

Commit dd522ac

Browse files
committed
implement solution for optionals 01
1 parent f625ac7 commit dd522ac

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Exercise.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public class Exercise {
44

55
public static void main(String[] args) {
6-
BookCollection collection = new BookCollection(new HashMap<>());
6+
BookCollection collection = new BookCollection(new HashMap<>());
77

88
try {
99
collection.addAuthor(new Author("Stephen King"));
@@ -21,7 +21,10 @@ public static void main(String[] args) {
2121
collection.addBook(new Author("George RR Martin"), new Book("Das Lied von Eis und Feuer 5"));
2222
collection.addBook(new Author("George RR Martin"), new Book("Das Lied von Eis und Feuer 6"));
2323

24-
System.out.println(collection.getBookByTitle("Das Lied von Eis und Feuer 5"));
25-
System.out.println(collection.getMostDiligentAuthor());
24+
collection.getBookByTitle("Das Lied von Eis und Feuer 5").ifPresentOrElse(System.out::println,
25+
() -> System.out.println("Das gesuchte Buch ist nicht vorhanden"));
26+
collection.getMostDiligentAuthor().ifPresentOrElse(System.out::println,
27+
() -> System.out.println("Es ist kein entsprechender Autor vorhanden"));
28+
2629
}
2730
}

0 commit comments

Comments
 (0)