Skip to content

Commit 7f0ea39

Browse files
committed
refactor: 입력시 throw IOException 예외 명시 삭제
1 parent 9a5ca2e commit 7f0ea39

File tree

6 files changed

+8
-19
lines changed

6 files changed

+8
-19
lines changed

calculator/src/main/java/com/wonu606/Main.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static void main(String[] args) {
2525
}
2626
}
2727

28-
private static void runApp(App app, Input input, Print printer) throws IOException {
28+
private static void runApp(App app, Input input, Print printer) {
2929
app.execute(input, printer);
3030
}
3131
}

calculator/src/main/java/com/wonu606/app/App.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77
public interface App {
88

9-
void execute(Input input, Print printer) throws IOException;
9+
void execute(Input input, Print printer);
1010
}

calculator/src/main/java/com/wonu606/calculator/CalculatorApp.java

+1-10
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
import com.wonu606.io.Input;
88
import com.wonu606.io.Print;
99
import com.wonu606.util.Message;
10-
import java.io.IOException;
11-
import java.util.ArrayList;
1210
import java.util.HashMap;
13-
import java.util.List;
1411
import java.util.Map;
1512
import java.util.Optional;
1613

@@ -46,12 +43,6 @@ private CalculatorStrategy getStrategyOrThrow(String selection) {
4643
}
4744

4845
private String inputMenuSelection(Input input) {
49-
while (true) {
50-
try {
51-
return input.getInput();
52-
} catch (IOException e) {
53-
e.printStackTrace();
54-
}
55-
}
46+
return input.getInput();
5647
}
5748
}

calculator/src/main/java/com/wonu606/io/ConsoleInput.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class ConsoleInput implements Input {
88
Scanner scanner = new Scanner(System.in);
99

1010
@Override
11-
public String getInput() throws IOException {
11+
public String getInput() {
1212
return scanner.nextLine();
1313
}
1414

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package com.wonu606.io;
22

3-
import java.io.IOException;
4-
53
public interface Input {
64

7-
String getInput() throws IOException;
5+
String getInput();
86

97
void tearDown();
108
}

calculator/src/test/java/com/wonu606/io/ConsoleInputTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ConsoleInputTest {
1212

1313
@Test
1414
@DisplayName("메뉴 입력")
15-
void testMenuSelectionInput() throws IOException {
15+
void testMenuSelectionInput() {
1616
String menuSelection = "1";
1717
InputStream in = new ByteArrayInputStream(menuSelection.getBytes());
1818
System.setIn(in);
@@ -24,7 +24,7 @@ void testMenuSelectionInput() throws IOException {
2424

2525
@Test
2626
@DisplayName("표현식 입력")
27-
void testExpressionInput() throws IOException {
27+
void testExpressionInput() {
2828
String expression = "2 + 3";
2929
InputStream in = new ByteArrayInputStream(expression.getBytes());
3030
System.setIn(in);
@@ -36,7 +36,7 @@ void testExpressionInput() throws IOException {
3636

3737
@Test
3838
@DisplayName("개행 입력")
39-
void testNewLineInput() throws IOException {
39+
void testNewLineInput() {
4040
String newLine = "\n";
4141
InputStream in = new ByteArrayInputStream(newLine.getBytes());
4242
System.setIn(in);

0 commit comments

Comments
 (0)