Aufgabe 6
a)
public Set<String> getAlleKinder(String mutter) {
return mutterVonKind.entrySet().stream()
.filter(entry -> entry.getValue().equals(mutter))
.map(entry -> entry.getKey())
.collect(Collectors.toSet());
}
b)
public Set<String> getAlleGeschwister(String kind) {
String mutter = mutterVonKind.get(kind);
return mutterVonKind.entrySet().stream()
.filter(entry -> entry.getValue().equals(mutter)
&& !entry.getKey().equals(kind))
.map(entry -> entry.getKey())
.collect(Collectors.toSet());
}
c)
public boolean istTanteVon(String x, String y) {
return getAlleGeschwister(mutterVonKind.get(y))
.contains(x);
}