-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOperator.java
More file actions
32 lines (29 loc) · 765 Bytes
/
Copy pathOperator.java
File metadata and controls
32 lines (29 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
public class Operator {
private final int PRECEDENCE;
private final char SYMBOL;
public Operator(Character op){
this.SYMBOL = op;
this.PRECEDENCE = setPrecedence(op);
}
private int setPrecedence(Character op){
return switch (op) {
case ')' -> 0;
case '(' -> 9;
case '¬' -> 1;
case '∧' -> 2;
case '∨' -> 3;
case '→' -> 4;
case '↔' -> 5;
case '↑' -> 6;
case '↓' -> 7;
case '⊻' -> 8;
default -> -1;
};
}
public char getSYMBOL() {
return SYMBOL;
}
public int getPrecedence(){
return PRECEDENCE;
}
}