forked from Lunya-sh/Evil_Calculator
removed unnecessary this. and .ToString and type specifying
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
{
|
||||
internal class ReverseNotationSolver
|
||||
{
|
||||
List<Token> equation = new List<Token>();
|
||||
List<Token> equation = new();
|
||||
|
||||
public string? ToReverseNotation(ref List<Token> equation)
|
||||
public string ToReverseNotation(ref List<Token> equation)
|
||||
{
|
||||
List<Token> TEMP = new List<Token>();
|
||||
Stack<Token> OPERATORS = new Stack<Token>();
|
||||
@@ -30,7 +30,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
while (OPERATORS.Count != 0 ? OPERATORS.Peek().priority >= token.priority : false)
|
||||
while (OPERATORS.Count != 0 && OPERATORS.Peek().priority >= token.priority)
|
||||
{
|
||||
TEMP.Add(OPERATORS.Pop());
|
||||
}
|
||||
@@ -46,9 +46,8 @@
|
||||
return equationToString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public string? Solve(ref List<Token> equation)
|
||||
|
||||
public string Solve(ref List<Token> equation)
|
||||
{
|
||||
ToReverseNotation(ref equation);
|
||||
Stack<Token> stack = new Stack<Token>();
|
||||
@@ -99,18 +98,15 @@
|
||||
return stack.Pop().value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public string equationToString()
|
||||
{
|
||||
string equationString = "";
|
||||
foreach (Token token in this.equation)
|
||||
foreach (Token token in equation)
|
||||
{
|
||||
equationString += token.value.ToString() + " ";
|
||||
equationString += token.value + " ";
|
||||
}
|
||||
return equationString;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user