removed unnecessary this. and .ToString and type specifying

This commit is contained in:
2026-01-11 02:23:50 +05:00
parent d1058d8fd5
commit e09e81073b
4 changed files with 73 additions and 76 deletions

View File

@@ -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;
}
}
}