Skip to content

Commit 4956631

Browse files
committed
Add comments a bit to GettingCloserToTheTarget task. Change DTO to record class
1 parent a80e6a2 commit 4956631

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

src/main/java/by/andd3dfx/numeric/GettingCloserToTheTarget.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,10 @@ public static boolean isPossibleToReachTheTarget(Condition condition) {
3232
}
3333

3434
@Builder
35-
public static class Condition {
35+
public record Condition(double x0, double y0, double vx, double vy,
36+
double vRocket,
37+
double t, double distance
38+
) {
3639

37-
double x0;
38-
double y0;
39-
double vx;
40-
double vy;
41-
double vRocket;
42-
double t;
43-
double distance;
4440
}
4541
}

src/test/java/by/andd3dfx/numeric/GettingCloserToTheTargetTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ public class GettingCloserToTheTargetTest {
1010
@Test
1111
public void isPossibleToReachTheTarget() {
1212
Condition condition = Condition.builder()
13-
.x0(1)
14-
.y0(1)
13+
.x0(1) // 1 - 0.5*10 = 1-5 = -4
14+
.y0(1) // 1 + 0.5*10 = 1+5 = 6, hypotenuse: 4^2 + 6^2 = 52 = (7.xx)^2
1515
.vx(-0.5)
1616
.vy(0.5)
17-
.vRocket(0.6)
17+
.vRocket(0.6) // need to compare: 6 and 7.2
1818
.t(10)
1919
.distance(1)
2020
.build();
2121
assertThat(GettingCloserToTheTarget.isPossibleToReachTheTarget(condition)).isFalse();
2222

2323
Condition condition2 = Condition.builder()
24-
.x0(1)
25-
.y0(1)
24+
.x0(1) // 1 - 0.5*10 = 1-5 = -4
25+
.y0(1) // 1 + 0.5*10 = 1+5 = 6, hypotenuse: 4^2 + 6^2 = 52 = (7.xx)^2
2626
.vx(-0.5)
2727
.vy(0.5)
28-
.vRocket(0.65)
28+
.vRocket(0.65) // need to compare: 6.5 and 7.2
2929
.t(10)
3030
.distance(1)
3131
.build();

0 commit comments

Comments
 (0)