File tree 3 files changed +12
-5
lines changed
main/java/com/thealgorithms/maths
test/java/com/thealgorithms
3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 12
12
*/
13
13
public final class MathBuilder {
14
14
private final double result ;
15
+
15
16
private MathBuilder (Builder builder ) {
16
17
this .result = builder .number ;
17
18
}
19
+
18
20
// Returns final result
19
21
public double get () {
20
22
return result ;
21
23
}
24
+
22
25
// Return result in long
23
26
public long toLong () {
24
27
try {
@@ -46,12 +49,15 @@ public long toLong() {
46
49
public static class Builder {
47
50
private double number ;
48
51
private double memory = 0 ;
52
+
49
53
public Builder () {
50
54
number = 0 ;
51
55
}
56
+
52
57
public Builder (double num ) {
53
58
number = num ;
54
59
}
60
+
55
61
public Builder add (double num ) {
56
62
number += num ;
57
63
return this ;
@@ -324,7 +330,8 @@ public Builder format(String format) {
324
330
}
325
331
326
332
public Builder format (int decimalPlace ) {
327
- String pattern = "." + "#" .repeat (decimalPlace );
333
+ String pattern = "."
334
+ + "#" .repeat (decimalPlace );
328
335
DecimalFormat formater = new DecimalFormat (pattern );
329
336
String num = formater .format (number );
330
337
number = Double .parseDouble (num );
Original file line number Diff line number Diff line change 1
1
package com .thealgorithms .maths ;
2
2
3
- import org .junit .jupiter .api .Test ;
4
-
5
3
import static org .junit .jupiter .api .Assertions .assertEquals ;
6
4
import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
7
5
6
+ import org .junit .jupiter .api .Test ;
7
+
8
8
class MathBuilderTest {
9
9
10
10
@ Test
Original file line number Diff line number Diff line change 1
1
package com .thealgorithms .others ;
2
2
3
- import java . util . List ;
3
+ import static org . junit . jupiter . api . Assertions . assertIterableEquals ;
4
4
5
+ import java .util .List ;
5
6
import org .junit .jupiter .api .Test ;
6
7
7
- import static org .junit .jupiter .api .Assertions .assertIterableEquals ;
8
8
9
9
public class TestPrintMatrixInSpiralOrder {
10
10
@ Test
You can’t perform that action at this time.
0 commit comments