Skip to content

Commit ea11011

Browse files
authored
Make example in Darts approach more idiomatic (#2884)
It is more idiomatic to use SCREAMING_SNAKE_CASE for static constant names and `private static final` instead of `final static private`.
1 parent a73fb98 commit ea11011

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

exercises/practice/darts/.approaches/introduction.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@ import java.util.function.DoublePredicate;
3939

4040
class Darts {
4141

42-
final private static double innerRing = 1.0;
43-
final private static double middleRing = 5.0;
44-
final private static double outerRing = 10.0;
42+
private static final double INNER_RING = 1.0;
43+
private static final double MIDDLE_RING = 5.0;
44+
private static final double OUTER_RING = 10.0;
4545

4646
int score(double x, double y) {
4747
var pointRadius = (Math.sqrt((x * x) + (y * y)));
4848
DoublePredicate thrownOutside = ring -> pointRadius > ring;
4949

50-
if (thrownOutside.test(outerRing))
50+
if (thrownOutside.test(OUTER_RING))
5151
return 0;
52-
if (thrownOutside.test(middleRing))
52+
if (thrownOutside.test(MIDDLE_RING))
5353
return 1;
54-
if (thrownOutside.test(innerRing))
54+
if (thrownOutside.test(INNER_RING))
5555
return 5;
5656
return 10;
5757
}

0 commit comments

Comments
 (0)