-
Notifications
You must be signed in to change notification settings - Fork 183
Expand file tree
/
Copy pathFunction_03_Test.java
More file actions
46 lines (35 loc) · 1.33 KB
/
Function_03_Test.java
File metadata and controls
46 lines (35 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package java17.ex03;
import java.util.function.BinaryOperator;
import org.junit.Test;
import java17.data.Person;
/**
* Exercice 03 - java.util.function.BinaryOperator
*/
public class Function_03_Test {
// tag::makeAChild[]
// TODO Compléter la fonction makeAChild
// TODO l'enfant possède le nom du père
// TODO l'enfant possède le prenom "<PRENOM_PERE> <PRENOM_MERE>"
// TODO l'age de l'enfant est 0
// TODO le mot de passe de l'enfant est null
BinaryOperator<Person> makeAChild = (Person father, Person mother) -> {
Person child = new Person();
child.setFirstname(father.getFirstname() + " " + mother.getFirstname());
child.setLastname(father.getLastname());
child.setAge(0);
child.setPassword(null);
return child;
};
// end::makeAChild[]
@Test
public void test_makeAChild() throws Exception {
Person father = new Person("John", "France", 25, "johndoe");
Person mother = new Person("Aline", "Lebreton", 22, "alino");
// TODO compléter le test pour qu'il soit passant
Person child = makeAChild.apply(father, mother);
assert child.getFirstname().equals("John Aline");
assert child.getLastname().equals("France");
assert child.getAge().equals(0);
assert child.getPassword() == null;
}
}