Skip to content

Commit 452b9f9

Browse files
author
Julien Letrouit
committed
Finalized translation of AboutInterfaces in french
1 parent 26b79b1 commit 452b9f9

18 files changed

Lines changed: 214 additions & 198 deletions

CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,15 @@ We expressed above a concern for saving student's attention / motivation / time.
7979
Pull requests for translations, curiculum tweaks or new capabilities are welcome.
8080

8181
When submitting bugs, please submit a zip file of the koans in a state exhibiting the issue.
82+
83+
## Testing
84+
85+
Testing this kind of project is challenging for a few reasons, main ones being:
86+
87+
1. By design, we don't have a build tool (Gradle or Maven for example), nor access to any libraries. So no JUnit on hand.
88+
2. We would not want to include solutions to the koans within the project, because the students might stumble on them, which would affect their learning.
89+
90+
For 1., we have created a mini test framework in `engine.test.runner` in order to run unit and integration tests of the koans engine. Tests are located in `engine.test`. To run those tests, simply run the `engine.test.runner.TestRunner.main` method.
91+
92+
For 2., we have created a [brother project](https://github.com/jletroui/FrcJavaKoansTests) testing the koans themselves.
93+

src/main/java/bonuses/english/AboutInterfaces.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ public class AboutInterfaces {
101101
*
102102
* --------- TIPS --------------
103103
*
104-
* Sometimes, it is tedious to create a class file to implement an interface just for one occasion.
105-
* In these situation, you can implement the interface in an anonymous class. It is anonymous, because it does not have a name.
104+
* Sometimes, creating a file and a public class is a lot of work when we implement a simple interface, and we only use it in a single place.
105+
* In such a situation, you can implement the interface in an anonymous class. It is anonymous, because it does not have a name.
106106
* That class is instantiated immediately where it is created. For example:
107107
*
108108
* public Weapon toss() {
@@ -115,7 +115,7 @@ public class AboutInterfaces {
115115
* }
116116
*
117117
* When looking at this code, you could be tempted to believe there is a constructor for the interface Weapon, but there is not.
118-
* We are really creating a class, for which there exists a single object.
118+
* We are really creating a class, for which the only place we will create objects is this 'toss()' method.
119119
* The constructor with empty parameters is the one of this nameless class.
120120
* We can now get and use the tossed weapon this way:
121121
*
@@ -139,7 +139,7 @@ public class AboutInterfaces {
139139
*
140140
* --------- TIPS --------------
141141
*
142-
* When an interface have only one method, there is an even shorter form to implement it. You can use what is called a 'lambda method'.
142+
* When an interface have only one method, there is an even shorter form to implement it. You can create what is called a "lambda method".
143143
* A 'lambda method' is a stripped down version of a method. Since our example interface 'Weapon' has only a single method 'hit()', we can use this shortcut:
144144
*
145145
* For example:
@@ -155,17 +155,17 @@ public class AboutInterfaces {
155155
* Weapon tossedWeapon = toss();
156156
* tossedWeapon.hit(zombie);
157157
*
158-
* The general syntax for lambda method returning void, or having a body with multiple lines:
158+
* The general syntax for lambda method having a body with multiple lines is:
159159
*
160160
* ([param1Name], [param2Name], ...) -> {
161161
* // Lambda method body here
162162
* }
163163
*
164-
* If your lambda is having a single expression, you can even skip the parentheses and the 'return':
164+
* If your lambda is having a single expression, you can even skip the curly brackets and the 'return' statement:
165165
*
166166
* ([param1Name], [param2Name], ...) -> // expression here
167167
*
168-
* Here are some example of methods and their lambda equivalent (assuming the interface has only one method in it):
168+
* Here are some example of methods and their lambda equivalent (assuming the interface has only one of these methods in its contract):
169169
*
170170
* This interface implementation:
171171
*
@@ -175,9 +175,7 @@ public class AboutInterfaces {
175175
*
176176
* Can be replaced by this lambda:
177177
*
178-
* () -> {
179-
* System.out.println("hello");
180-
* }
178+
* () -> System.out.println("hello")
181179
*
182180
* This interface implementation:
183181
*
@@ -223,27 +221,30 @@ public class AboutInterfaces {
223221
*
224222
* --------- TIPS --------------
225223
*
226-
* Since lambda methods are so useful, a lot of interfaces already exist in the Java standard library, and we don't have to create them ourselves.
224+
* Note: the {@link java.lang.String} notation allows to show a link to a class in a comment. To see the class, you can [CTRL] + clic on its name.
227225
*
228-
* For example:
226+
* Since lambda methods are so useful, a lot of simple interfaces already exist in the Java standard library, and we don't have to create them ourselves.
227+
* For example, an interface with a method having the same signature as the 'combine()' method already exists. It is called the {@link java.util.function.IntBinaryOperator}.
228+
*
229+
* Other examples:
229230
*
230231
* For a lambda taking no parameter, and returning nothing, {@link java.lang.Runnable}:
231232
*
232-
* Runnable sayHello = () -> { System.out.println("Hello"); };
233+
* Runnable sayHello = () -> System.out.println("Hello");
233234
*
234-
* For a lambda taking a int parameter, and returning nothing, {@link java.util.function.IntConsumer}:
235+
* For a lambda taking a 'int' parameter, and returning nothing, {@link java.util.function.IntConsumer}:
235236
*
236-
* IntConsumer displayInt = (anInt) -> { System.out.println(anInt); };
237+
* IntConsumer displayInt = (anInt) -> System.out.println(anInt);
237238
*
238-
* The same exist for other type. For example {@link java.util.function.DoubleConsumer}:
239+
* The same exist for other parameter types. For example {@link java.util.function.DoubleConsumer}:
239240
*
240-
* DoubleConsumer displayDouble = (aDouble) -> { System.out.println(aDouble); };
241+
* DoubleConsumer displayDouble = (aDouble) -> System.out.println(aDouble);
241242
*
242-
* The reverse functions, taking nothing as a parameter, but returning something exist as well: {@link java.util.function.IntSupplier}, {@link java.util.function.DoubleSupplier}. etc...
243+
* The reverse methods, taking no parameter, but returning something exist as well: {@link java.util.function.IntSupplier}, {@link java.util.function.DoubleSupplier}. etc...
243244
*
244245
* DoubleSupplier giveMePiPleeeaaase = () -> 3.14159;
245246
*
246-
* There is also a lot of case where you would need to test a number somehow. This is where interfaces like {@link java.util.function.IntPredicate} shine:
247+
* There is also a lot of case where you would need to test if a number respect a certain condition. This is where "predicate" interfaces like {@link java.util.function.IntPredicate} shine:
247248
*
248249
* IntPredicate isPositive = (number) -> number >= 0;
249250
*

src/main/java/bonuses/french/AboutInterfaces.java

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -94,28 +94,28 @@ public class AboutInterfaces {
9494
/**
9595
* # Anonymous interface implementation
9696
*
97-
* Write a method 'getAnonymousCombining' which returns an anonymous implementation of 'bonuses.teachingmaterial.Combining'.
98-
* The implementation of the combine() method devrait retourner the second number subtracted from the first.
97+
* Écris une méthode 'getAnonymousCombining' qui retourne une implémentation anonyme de 'bonuses.teachingmaterial.Combining'.
98+
* L'implémentation de la méthode combine() devrait retourner le 2ème nombre soustrait du 1er.
9999
*
100100
* --------- TIPS --------------
101101
*
102-
* Sometimes, it is tedious to create a class file to implement an interface just for one occasion.
103-
* In these situation, you can implement the interface in an anonymous class. It is anonymous, because it does not have a name.
104-
* That class is instantiated immediately where it is created. For example:
102+
* Parfois, créer un fichier et une classe publique représente beaucoup de travail lorsque l'on implémente une interface simple, et qu'on l'utilise à un seul endroit dans le code.
103+
* Dans cette situation, tu peux implémenter une interface dans une classe anonyme. La classe est anonyme car elle n'a pas de nom.
104+
* Cette classe est instantiée en un object immédiatement où elle est définie. Par exemple:
105105
*
106106
* public Weapon toss() {
107107
* return new Weapon() {
108108
* @Override
109109
* public void hit(Monster monster) {
110-
* // Some code computing and applying damage to the monster, applying some tear and wear on the weapon, etc...
110+
* // Du code qui calcule et applique le dommage, applique de l'usure à l'arme, etc...
111111
* }
112112
* }
113113
* }
114114
*
115-
* When looking at this code, you could be tempted to believe there is a constructor for the interface Weapon, but there is not.
116-
* We are really creating a class, for which there exists a single object.
117-
* The constructor with empty parameters is the one of this nameless class.
118-
* We can now get and use the tossed weapon this way:
115+
* Quand on considère ce code, on pourrait être tenté de croire qu'il y a un constructeur pour l'interface 'Weapon', mais évidemment, une interface n'a pas de constructeur, puisque c'est un simple "contrat".
116+
* Ici, nous créons vraiment une classe, pour laquelle le seul endroit où des objets vont être créés est la méthode 'toss()'.
117+
* Le constructeur sans paramètre est celui de cette classe sans nom.
118+
* Nous pouvons maintenant utiliser cette arme envoyée de cette manière:
119119
*
120120
* Weapon tossedWeapon = toss();
121121
* tossedWeapon.hit(zombie);
@@ -130,64 +130,62 @@ public class AboutInterfaces {
130130

131131

132132
/**
133-
* # Lambda methods
133+
* # Méthodes lambda
134134
*
135-
* Write a method 'getLambdaCombining' which returns an lambda method implementing 'bonuses.teachingmaterial.Combining'.
136-
* The implementation of the combine() method devrait retourner the first number subtracted from the second.
135+
* Écris une méthode 'getLambdaCombining' qui retourne une méthode lambda implémentant 'bonuses.teachingmaterial.Combining'.
136+
* L'implémentation de la méthode combine() devrait retourner le 1er nombre soustrait du 2ème.
137137
*
138138
* --------- TIPS --------------
139139
*
140-
* When an interface have only one method, there is an even shorter form to implement it. You can use what is called a 'lambda method'.
141-
* A 'lambda method' is a stripped down version of a method. Since our example interface 'Weapon' has only a single method 'hit()', we can use this shortcut:
140+
* Quand une interface a une seule méthode, il exist une forme encore plus courte pour l'implémenter. Tu peux créer ce que l'on appelle une "méthode lambda".
141+
* Une "méthode lambda" est une version raccourcie d'une méthode. Comme notre interface exemple 'Weapon' ne contient qu'une seule méthode 'hit()', nous pouvons utiliser ce raccourci.
142142
*
143-
* For example:
143+
* Par example:
144144
*
145145
* public Weapon toss() {
146146
* return (monster) -> {
147-
* // Some code computing and applying damage to the monster, applying some tear and wear on the weapon, etc..
147+
* // Du code qui calcule et applique le dommage, applique de l'usure à l'arme, etc...
148148
* };
149149
* }
150150
*
151-
* We can now get and use the tossed weapon this way:
151+
* Nous pouvons maintenant utiliser cette arme envoyée de cette manière:
152152
*
153153
* Weapon tossedWeapon = toss();
154154
* tossedWeapon.hit(zombie);
155155
*
156-
* The general syntax for lambda method returning void, or having a body with multiple lines:
156+
* La syntaxe générale pour une méthode lambda dont l'implémentation est constituée de plusieurs lignes est la suivante:
157157
*
158-
* ([param1Name], [param2Name], ...) -> {
159-
* // Lambda method body here
158+
* ([nomParam1], [nomParam2], ...) -> {
159+
* // Corps de la méthode lambda ici
160160
* }
161161
*
162-
* If your lambda is having a single expression, you can even skip the parentheses and the 'return':
162+
* Si ta lambda a une seule expression, tu peux même enlever les accolades et l'instruction 'return':
163163
*
164-
* ([param1Name], [param2Name], ...) -> // expression here
164+
* ([nomParam1], [nomParam2], ...) -> // expression ici
165165
*
166-
* Here are some example of methods and their lambda equivalent (assuming the interface has only one method in it):
166+
* Voici quelques exemples de méthodes et leur équivalent lambda (en supposant que l'interface n'a qu'une seule de ces méthodes dans son contrat):
167167
*
168-
* This interface implementation:
168+
* L'implémentation de cette méthode:
169169
*
170170
* public void sayHello() {
171171
* System.out.println("hello");
172172
* }
173173
*
174-
* Can be replaced by this lambda:
174+
* Peut être remplacée par cette lambda:
175175
*
176-
* () -> {
177-
* System.out.println("hello");
178-
* }
176+
* () -> System.out.println("hello")
179177
*
180-
* This interface implementation:
178+
* L'implémentation de cette méthode:
181179
*
182180
* public int square(int x) {
183181
* return x * x;
184182
* }
185183
*
186-
* Can be replaced by this lambda:
184+
* Peut être remplacée par cette lambda:
187185
*
188186
* (x) -> x * x
189187
*
190-
* This interface implementation:
188+
* L'implémentation de cette méthode:
191189
*
192190
* public int min(int x, int y) {
193191
* if (x < y) {
@@ -196,7 +194,7 @@ public class AboutInterfaces {
196194
* return y;
197195
* }
198196
*
199-
* Can be replaced by this lambda:
197+
* Peut être remplacée par cette lambda:
200198
*
201199
* (x, y) -> {
202200
* if (x < y) {
@@ -215,39 +213,42 @@ public class AboutInterfaces {
215213

216214

217215
/**
218-
* # Common lambda interfaces
216+
* # Interfaces lambda communes
219217
*
220-
* Write a method 'getIsEven' which returns a lambda method testing if an integer is even.
218+
* Écris une méthode 'getIsEven' qui retourne une méthode lambda testant si un entier est pair.
221219
*
222220
* --------- TIPS --------------
223221
*
224-
* Since lambda methods are so useful, a lot of interfaces already exist in the Java standard library, and we don't have to create them ourselves.
222+
* Note: la notation {@link java.lang.String} permet de montrer un lien vers une classe dans un commentaire. Pour voir la classe, tu peux faire un [CTRL] + clic sur le nom de la classe.
223+
*
224+
* Comme les méthodes lambdas sont si pratiques, beaucoup d'interfaces simples existent déjà dans la librairie standard de Java. Nous n'avons pas besoin de les créer nous même.
225+
* Par exemple, une interface avec une méthode ayant la même signature que 'combine()' existe déjà. C'est {@link java.util.function.IntBinaryOperator}.
225226
*
226-
* For example:
227+
* D'autres exemples:
227228
*
228-
* For a lambda taking no parameter, and returning nothing, {@link java.lang.Runnable}:
229+
* Pour une lambda sans paramètre, et ne retournant rien, {@link java.lang.Runnable}:
229230
*
230-
* Runnable sayHello = () -> { System.out.println("Hello"); };
231+
* Runnable sayHello = () -> System.out.println("Hello");
231232
*
232-
* For a lambda taking a int parameter, and returning nothing, {@link java.util.function.IntConsumer}:
233+
* Pour une lambda prenant un paramètre 'int', et ne retournant rien, {@link java.util.function.IntConsumer}:
233234
*
234-
* IntConsumer displayInt = (anInt) -> { System.out.println(anInt); };
235+
* IntConsumer displayInt = (anInt) -> System.out.println(anInt);
235236
*
236-
* The same exist for other type. For example {@link java.util.function.DoubleConsumer}:
237+
* La même chose existe pour d'autres types de paramètres. Par exemple {@link java.util.function.DoubleConsumer}:
237238
*
238-
* DoubleConsumer displayDouble = (aDouble) -> { System.out.println(aDouble); };
239+
* DoubleConsumer displayDouble = (aDouble) -> System.out.println(aDouble);
239240
*
240-
* The reverse functions, taking nothing as a parameter, but returning something exist as well: {@link java.util.function.IntSupplier}, {@link java.util.function.DoubleSupplier}. etc...
241+
* Les methodes inverses, ne prenant aucun paramètre, mais retournant un résultat, existent aussi: {@link java.util.function.IntSupplier}, {@link java.util.function.DoubleSupplier}. etc...
241242
*
242243
* DoubleSupplier giveMePiPleeeaaase = () -> 3.14159;
243244
*
244-
* There is also a lot of case where you would need to test a number somehow. This is where interfaces like {@link java.util.function.IntPredicate} shine:
245+
* Un cas courant est lorsque nous avons besoin de tester si un nombre respecte une condition. C'est là que les interfaces "prédicat" brillent, comme {@link java.util.function.IntPredicate}:
245246
*
246247
* IntPredicate isPositive = (number) -> number >= 0;
247248
*
248-
* For the exercise, you can use the modulo operator, %, which computes the remainder of an integer division:
249+
* Pour cet exercice, tu peux utiliser l'opérateur modulo, %, qui calcule le reste d'une division entière:
249250
*
250-
* int remainder = 17 % 5; // remainder equals 2
251+
* int remainder = 17 % 5; // remainder vaut 2
251252
*
252253
* -------------------------------
253254
*

src/main/java/engine/Assertions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public static ResultAssertion assertReturnValueIsLambda() {
300300
} else if (res.executionResult.getClass().isAnonymousClass()) {
301301
p.println(format(EXPECTED_TO_RETURN_LAMBDA_BUT_RETURNED_ANONYMOUS, Formats.Red, code(res.resultExpressionSourceCode)));
302302
return false;
303-
} else if (!res.executionResult.getClass().getSimpleName().contains("$$Lambda$")) { // Kind of hacky, but only way as far as I know
303+
} else if (!res.executionResult.getClass().getSimpleName().contains("$$Lambda")) { // Kind of hacky, but only way as far as I know
304304
p.println(format(EXPECTED_TO_RETURN_LAMBDA_BUT_RETURNED, Formats.Red, code(res.resultExpressionSourceCode), code(res.executionResult.getClass().getName())));
305305
return false;
306306
}

0 commit comments

Comments
 (0)