Skip to content

Commit ae74fa5

Browse files
committed
feat: 연산자 우선순위 Enum 정의
1 parent 119841a commit ae74fa5

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package stack;
2+
3+
public enum OperatorPriority {
4+
TOP(3),
5+
MID(2),
6+
BOT(1),
7+
NONE(-1);
8+
9+
private final int priority;
10+
11+
OperatorPriority(int priority) {
12+
this.priority = priority;
13+
}
14+
15+
public static OperatorPriority getOperatorPriority(char sign) {
16+
switch (sign) {
17+
case '*':
18+
case '/':
19+
return TOP;
20+
case '+':
21+
case '-':
22+
return MID;
23+
case '(':
24+
return BOT;
25+
default:
26+
return NONE;
27+
}
28+
}
29+
30+
public int getPriority() {
31+
return priority;
32+
}
33+
34+
35+
}

0 commit comments

Comments
 (0)