-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSemicolon.java
38 lines (33 loc) · 1015 Bytes
/
Semicolon.java
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
33
34
35
36
37
38
package proj4;
/**
* SEMICOLON CLASS
* A token that is not an operator. It is handled a certain way to convert from infix to postfix notation
* @author Jordan An
* @version 28/05/2020
*/
public class Semicolon implements Token{
/** Processes the current token. Since every token will handle
* itself in its own way, handling may involve pushing or
* popping from the given stack and/or appending more tokens
* to the output string.
*
* @param s the Stack the token uses, if necessary, when processing itself.
* @return String to be appended to the output
*/
public String handle(Stack<Token> s){
Token tempToken;
String ans = "";
while(!s.isEmpty()){
tempToken = s.pop();
ans += tempToken.toString();
}
return ans;
}
/** Returns the token as a printable String
*
* @return the String version of the token.
*/
public String toString(){
return ";";
}
}