File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed
main/java/com/thealgorithms/maths
test/java/com/thealgorithms Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 1212 */
1313public final class MathBuilder {
1414 private final double result ;
15+
1516 private MathBuilder (Builder builder ) {
1617 this .result = builder .number ;
1718 }
19+
1820 // Returns final result
1921 public double get () {
2022 return result ;
2123 }
24+
2225 // Return result in long
2326 public long toLong () {
2427 try {
@@ -46,12 +49,15 @@ public long toLong() {
4649 public static class Builder {
4750 private double number ;
4851 private double memory = 0 ;
52+
4953 public Builder () {
5054 number = 0 ;
5155 }
56+
5257 public Builder (double num ) {
5358 number = num ;
5459 }
60+
5561 public Builder add (double num ) {
5662 number += num ;
5763 return this ;
@@ -324,7 +330,8 @@ public Builder format(String format) {
324330 }
325331
326332 public Builder format (int decimalPlace ) {
327- String pattern = "." + "#" .repeat (decimalPlace );
333+ String pattern = "."
334+ + "#" .repeat (decimalPlace );
328335 DecimalFormat formater = new DecimalFormat (pattern );
329336 String num = formater .format (number );
330337 number = Double .parseDouble (num );
Original file line number Diff line number Diff line change 11package com .thealgorithms .maths ;
22
3- import org .junit .jupiter .api .Test ;
4-
53import static org .junit .jupiter .api .Assertions .assertEquals ;
64import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
75
6+ import org .junit .jupiter .api .Test ;
7+
88class MathBuilderTest {
99
1010 @ Test
Original file line number Diff line number Diff line change 11package com .thealgorithms .others ;
22
3- import java . util . List ;
3+ import static org . junit . jupiter . api . Assertions . assertIterableEquals ;
44
5+ import java .util .List ;
56import org .junit .jupiter .api .Test ;
67
7- import static org .junit .jupiter .api .Assertions .assertIterableEquals ;
88
99public class TestPrintMatrixInSpiralOrder {
1010 @ Test
You can’t perform that action at this time.
0 commit comments