Skip to content

Commit 57bb623

Browse files
refactor 504
1 parent ea5c918 commit 57bb623

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package com.fishercoder.solutions;
22

33
/**
4+
* 504. Base 7
5+
*
46
* Given an integer, return its base 7 string representation.
5-
67
Example 1:
78
Input: 100
89
Output: "202"
10+
911
Example 2:
1012
Input: -7
1113
Output: "-10"
@@ -14,7 +16,9 @@
1416
*/
1517
public class _504 {
1618

17-
public String convertToBase7(int num) {
18-
return String.valueOf(Integer.toString(num, 7));
19+
public static class Solution1 {
20+
public String convertToBase7(int num) {
21+
return String.valueOf(Integer.toString(num, 7));
22+
}
1923
}
2024
}

src/test/java/com/fishercoder/_504Test.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
* Created by fishercoder on 1/15/17.
1212
*/
1313
public class _504Test {
14-
private static _504 test;
14+
private static _504.Solution1 solution1;
1515
private static String expected;
1616
private static String actual;
1717
private static int num;
1818

1919
@BeforeClass
2020
public static void setup() {
21-
test = new _504();
21+
solution1 = new _504.Solution1();
2222
}
2323

2424
@Before
@@ -32,15 +32,15 @@ public void setupForEachTest() {
3232
public void test1() {
3333
num = 100;
3434
expected = "202";
35-
actual = test.convertToBase7(num);
35+
actual = solution1.convertToBase7(num);
3636
assertEquals(expected, actual);
3737
}
3838

3939
@Test
4040
public void test2() {
4141
num = -7;
4242
expected = "-10";
43-
actual = test.convertToBase7(num);
43+
actual = solution1.convertToBase7(num);
4444
assertEquals(expected, actual);
4545
}
4646
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy