-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToken.cs
More file actions
31 lines (27 loc) · 728 Bytes
/
Copy pathToken.cs
File metadata and controls
31 lines (27 loc) · 728 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
namespace reverse_polish_notation;
using System.Linq;
public class Token
{
public TokenType TokenType { get; }
public string Value { get; }
public double NumericValue { get; }
public bool IsOperator { get; }
public bool IsNumber { get; }
public Token(TokenType tokenType, string text)
{
Value = text;
TokenType = tokenType;
if (tokenType == TokenType.Number)
{
IsNumber = true;
IsOperator = false;
NumericValue = Double.Parse(text);
}
else if(tokenType == TokenType.Operator)
{
IsNumber = false;
IsOperator = true;
}
else throw new ArgumentException();
}
}