Skip to content

Commit d3d8e38

Browse files
refactor 319
1 parent e9632aa commit d3d8e38

File tree

2 files changed

+67
-70
lines changed

2 files changed

+67
-70
lines changed

src/main/java/com/fishercoder/solutions/_319.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
*/
2323
public class _319 {
2424

25-
public int bulbSwitch(int n) {
26-
if (n < 2) {
27-
return n;
25+
public static class Solution1 {
26+
public int bulbSwitch(int n) {
27+
if (n < 2) {
28+
return n;
29+
}
30+
return (int) Math.sqrt(n);
2831
}
29-
return (int) Math.sqrt(n);
3032
}
3133

3234
}

src/test/java/com/fishercoder/_319Test.java

Lines changed: 61 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -6,71 +6,66 @@
66

77
import static org.junit.Assert.assertEquals;
88

9-
/**
10-
* Created by stevesun on 6/6/17.
11-
*/
129
public class _319Test {
13-
private static _319 test;
14-
15-
@BeforeClass
16-
public static void setup() {
17-
test = new _319();
18-
}
19-
20-
@Test
21-
public void test1() {
22-
assertEquals(1, test.bulbSwitch(2));
23-
}
24-
25-
@Test
26-
public void test2() {
27-
assertEquals(1, test.bulbSwitch(3));
28-
}
29-
30-
@Test
31-
public void test3() {
32-
assertEquals(2, test.bulbSwitch(4));
33-
}
34-
35-
@Test
36-
public void test4() {
37-
assertEquals(2, test.bulbSwitch(5));
38-
}
39-
40-
@Test
41-
public void test5() {
42-
assertEquals(2, test.bulbSwitch(6));
43-
}
44-
45-
@Test
46-
public void test6() {
47-
assertEquals(2, test.bulbSwitch(7));
48-
}
49-
50-
@Test
51-
public void test7() {
52-
assertEquals(2, test.bulbSwitch(8));
53-
}
54-
55-
@Test
56-
public void test8() {
57-
assertEquals(3, test.bulbSwitch(9));
58-
}
59-
60-
@Test
61-
public void test11() {
62-
assertEquals(3, test.bulbSwitch(15));
63-
}
64-
65-
@Test
66-
public void test9() {
67-
assertEquals(4, test.bulbSwitch(17));
68-
}
69-
70-
@Test
71-
public void test10() {
72-
assertEquals(4, test.bulbSwitch(16));
73-
}
74-
75-
10+
private static _319.Solution1 solution1;
11+
12+
@BeforeClass
13+
public static void setup() {
14+
solution1 = new _319.Solution1();
15+
}
16+
17+
@Test
18+
public void test1() {
19+
assertEquals(1, solution1.bulbSwitch(2));
20+
}
21+
22+
@Test
23+
public void test2() {
24+
assertEquals(1, solution1.bulbSwitch(3));
25+
}
26+
27+
@Test
28+
public void test3() {
29+
assertEquals(2, solution1.bulbSwitch(4));
30+
}
31+
32+
@Test
33+
public void test4() {
34+
assertEquals(2, solution1.bulbSwitch(5));
35+
}
36+
37+
@Test
38+
public void test5() {
39+
assertEquals(2, solution1.bulbSwitch(6));
40+
}
41+
42+
@Test
43+
public void test6() {
44+
assertEquals(2, solution1.bulbSwitch(7));
45+
}
46+
47+
@Test
48+
public void test7() {
49+
assertEquals(2, solution1.bulbSwitch(8));
50+
}
51+
52+
@Test
53+
public void test8() {
54+
assertEquals(3, solution1.bulbSwitch(9));
55+
}
56+
57+
@Test
58+
public void test11() {
59+
assertEquals(3, solution1.bulbSwitch(15));
60+
}
61+
62+
@Test
63+
public void test9() {
64+
assertEquals(4, solution1.bulbSwitch(17));
65+
}
66+
67+
@Test
68+
public void test10() {
69+
assertEquals(4, solution1.bulbSwitch(16));
70+
}
7671
}

0 commit comments

Comments
 (0)