Skip to content

Commit d2a5d55

Browse files
committed
feat: 중위 표기법 입력을 계산하는 클래스를 클래스 합성을 통해 구현
1 parent 582571d commit d2a5d55

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package stack;
2+
3+
public class InfixCalculator {
4+
5+
InfixToPostfix infixToPostfix = new InfixToPostfix();
6+
PostCalculator postCalculator = new PostCalculator();
7+
8+
public int calculate(String input) {
9+
return postCalculator.calculate(infixToPostfix.convertInputToPostfix(input));
10+
}
11+
}

yoonexample/src/main/java/stack/InfixToPostfix.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
public class InfixToPostfix {
66

7+
public char[] convertInputToPostfix(String input) {
8+
return this.convertInfixToPostfix(this.convertInputToCharArray(input));
9+
}
10+
711
public char[] convertInputToCharArray(String input) {
812
return input.replace(" ", "").toCharArray();
913
}

yoonexample/src/test/java/stack/InfixCalculatorTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package stack;
22

3+
import static org.assertj.core.api.Assertions.assertThat;
4+
35
import org.junit.jupiter.api.BeforeEach;
46
import org.junit.jupiter.api.DisplayName;
57
import org.junit.jupiter.api.Test;

0 commit comments

Comments
 (0)