hw2: cleanup

This commit is contained in:
Claudio Maggioni 2022-10-19 13:27:26 +02:00
parent af7c772881
commit 6d56bcc5ce
2 changed files with 9 additions and 33 deletions

View file

@ -22,7 +22,7 @@ public class Main {
/**
* 3 Points
* TODO: Create a public static void function called "transformPeople".
* Create a public static void function called "transformPeople".
* input: a List from which People are read, called "src";
* a List in which People are inserted, called "dst".
* This function iterates over all the elements of "src" and copies them in the "dst" List.
@ -32,9 +32,9 @@ public class Main {
* Remember to use the get-put principle properly.
*/
public static void transformPeople(List<? extends People> src, List<? super People> dst) {
// true -> quelli con la z (lista)
// false -> quelli senza la z (lista)
Map<Boolean, List<People>> startsWithZPartitioned = src.stream().collect(
// true -> list of people whose names start with Z/z
// false -> list of all other people
final Map<Boolean, List<People>> startsWithZPartitioned = src.stream().collect(
Collectors.groupingBy(p -> p.getName().matches("^[zZ].*"))
);

View file

@ -1,24 +0,0 @@
package ch.usi.inf.ajp22;
class First {
void doSomething() {
System.out.println(" I am a class ");
}
}
interface Second {
default void doSomething() {
System.out.println(" I am an interface ");
}
}
public class Third extends First implements Second {
@Override
public void doSomething() {
super.doSomething();
}
public static void main(String[] args) {
Third third = new Third();
third.doSomething();
}
}