Skip to content

Commit

Permalink
Make example in Darts approach more idiomatic (#2884)
Browse files Browse the repository at this point in the history
It is more idiomatic to use SCREAMING_SNAKE_CASE for static constant names and `private static final` instead of `final static private`.
  • Loading branch information
josealonso authored Dec 30, 2024
1 parent a73fb98 commit ea11011
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions exercises/practice/darts/.approaches/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ import java.util.function.DoublePredicate;

class Darts {

final private static double innerRing = 1.0;
final private static double middleRing = 5.0;
final private static double outerRing = 10.0;
private static final double INNER_RING = 1.0;
private static final double MIDDLE_RING = 5.0;
private static final double OUTER_RING = 10.0;

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

if (thrownOutside.test(outerRing))
if (thrownOutside.test(OUTER_RING))
return 0;
if (thrownOutside.test(middleRing))
if (thrownOutside.test(MIDDLE_RING))
return 1;
if (thrownOutside.test(innerRing))
if (thrownOutside.test(INNER_RING))
return 5;
return 10;
}
Expand Down

0 comments on commit ea11011

Please sign in to comment.