Skip to content

Commit cbdfa53

Browse files
authored
Refactor SnellLaw class constructor and error handling
Refactor SnellLaw constructor and error message formatting.
1 parent 2251f27 commit cbdfa53

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/com/thealgorithms/physics/SnellLaw.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
* @see <a href="https://en.wikipedia.org/wiki/Snell%27s_law">Snell's Law</a>
77
*/
88
public final class SnellLaw {
9-
private SnellLaw() {
9+
10+
private SnellLaw() {
1011
throw new AssertionError("No instances.");
1112
}
13+
1214
/**
1315
* Computes the refracted angle (theta2) in radians.
1416
*
@@ -23,7 +25,9 @@ public static double refractedAngle(double n1, double n2, double theta1) {
2325
double sinTheta2 = ratio * Math.sin(theta1);
2426

2527
if (Math.abs(sinTheta2) > 1.0) {
26-
throw new IllegalArgumentException("Total internal reflection: no refraction possible.");
28+
throw new IllegalArgumentException(
29+
"Total internal reflection: no refraction possible."
30+
);
2731
}
2832

2933
return Math.asin(sinTheta2);

0 commit comments

Comments
 (0)