diff --git a/Evil Calculator.sln b/Evil Calculator.sln
new file mode 100644
index 0000000..a95165a
--- /dev/null
+++ b/Evil Calculator.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.13.35931.197 d17.13
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Evil Calculator", "Evil Calculator\Evil Calculator.csproj", "{942928AE-D155-4E97-A49D-174BFD563AF2}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {942928AE-D155-4E97-A49D-174BFD563AF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {942928AE-D155-4E97-A49D-174BFD563AF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {942928AE-D155-4E97-A49D-174BFD563AF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {942928AE-D155-4E97-A49D-174BFD563AF2}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {E9EA41D3-CF25-43D0-AC16-AFF63385DC7D}
+ EndGlobalSection
+EndGlobal
diff --git a/Evil Calculator/CalculatorBody.Designer.cs b/Evil Calculator/CalculatorBody.Designer.cs
new file mode 100644
index 0000000..ab0c989
--- /dev/null
+++ b/Evil Calculator/CalculatorBody.Designer.cs
@@ -0,0 +1,39 @@
+namespace Lunar.Evil_Calculator
+{
+ partial class CalculatorBody
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Text = "CalculatorBody";
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Evil Calculator/CalculatorBody.cs b/Evil Calculator/CalculatorBody.cs
new file mode 100644
index 0000000..5f9490b
--- /dev/null
+++ b/Evil Calculator/CalculatorBody.cs
@@ -0,0 +1,274 @@
+namespace Lunar.Evil_Calculator
+{
+ public partial class CalculatorBody : Form
+ {
+ private bool mouseDown;
+ private bool onTop;
+ private Point lastLocation;
+ private static Color LunarGray = System.Drawing.ColorTranslator.FromHtml("#2b292d");
+ private static Color LunarOrange = System.Drawing.ColorTranslator.FromHtml("#ff8700");
+
+ private Form CalculatorPanel = new Form();
+ private EquationManager equationManager = new EquationManager();
+
+
+ public CalculatorBody()
+ {
+ InitializeComponent();
+ this.BackColor = LunarGray;
+ this.Opacity = 0.75;
+ this.FormBorderStyle = FormBorderStyle.None;
+ this.ClientSize = new Size(300, 500);
+ this.Text = "Calculator";
+ MyTitleBar();
+ }
+
+ protected override void OnShown(EventArgs e)
+ {
+ base.OnShown(e);
+ CalculatorPanelInit();
+ }
+
+ protected override void OnMove(EventArgs e)
+ {
+ base.OnMove(e);
+ if (OwnedForms.Length > 0)
+ {
+ var p = PointToScreen(new Point(0, 30));
+ var dx = p.X - OwnedForms[0].Location.X;
+ var dy = p.Y - OwnedForms[0].Location.Y;
+ foreach (var f in OwnedForms)
+ f.Location = new Point(f.Location.X + dx, f.Location.Y + dy);
+ }
+ }
+
+ private void MyTitleBar()
+ {
+ Panel TitleBar = new Panel
+ {
+ Height = 30,
+ Dock = DockStyle.Top,
+ Visible = true
+ };
+
+ TitleBar.MouseDown += TitleBar_MouseDown;
+ TitleBar.MouseMove += TitleBar_MouseMove;
+ TitleBar.MouseUp += TitleBar_MouseUp;
+ this.Controls.Add(TitleBar);
+
+ Button ButtonMinimize = new Button
+ {
+ Text = "_",
+ Width = 40,
+ Height = TitleBar.Height,
+ Dock = DockStyle.Right,
+ FlatStyle = FlatStyle.Flat,
+ ForeColor = Color.White
+ };
+ ButtonMinimize.FlatAppearance.BorderSize = 0;
+ ButtonMinimize.FlatAppearance.BorderColor = LunarGray;
+ ButtonMinimize.Click += (s, e) => this.WindowState = FormWindowState.Minimized;
+ TitleBar.Controls.Add(ButtonMinimize);
+
+ Button ButtonMaximize = new Button
+ {
+ Text = "□",
+ Width = 40,
+ Height = TitleBar.Height,
+ Dock = DockStyle.Right,
+ FlatStyle = FlatStyle.Flat,
+ ForeColor = Color.White
+ };
+ ButtonMaximize.FlatAppearance.BorderSize = 0;
+ ButtonMaximize.FlatAppearance.BorderColor = LunarGray;
+ ButtonMaximize.Click += (s, e) =>
+ {
+ this.WindowState = (this.WindowState == FormWindowState.Normal) ? FormWindowState.Maximized : FormWindowState.Normal;
+ };
+ TitleBar.Controls.Add(ButtonMaximize);
+
+ Button ButtonClose = new Button
+ {
+ Text = "X",
+ Width = 40,
+ Height = TitleBar.Height,
+ Dock = DockStyle.Right,
+ FlatStyle = FlatStyle.Flat,
+ ForeColor = Color.White
+ };
+ ButtonClose.FlatAppearance.BorderSize = 0;
+ ButtonClose.FlatAppearance.BorderColor = LunarGray;
+ ButtonClose.Click += (s, e) => this.Close();
+ TitleBar.Controls.Add(ButtonClose);
+
+ Label titleLabel = new Label
+ {
+ Text = this.Text,
+ Location = new Point(8, 7),
+ AutoSize = true,
+ ForeColor = Color.White
+ };
+ TitleBar.Controls.Add(titleLabel);
+
+ void TitleBar_MouseDown(object? sender, MouseEventArgs e)
+ {
+ mouseDown = true;
+ lastLocation = e.Location;
+ }
+
+ void TitleBar_MouseMove(object? sender, MouseEventArgs e)
+ {
+ if (mouseDown)
+ {
+ this.Location = new Point(
+ (this.Location.X - lastLocation.X) + e.X, (this.Location.Y - lastLocation.Y) + e.Y);
+
+ this.Update();
+ }
+ }
+
+ void TitleBar_MouseUp(object? sender, MouseEventArgs e)
+ {
+ mouseDown = false;
+ }
+
+ void Titlebar_BaseTextChanged(object? sender, EventArgs e)
+ {
+ titleLabel.Text = this.Text;
+ }
+ this.TextChanged += Titlebar_BaseTextChanged;
+ }
+
+ private void CalculatorPanelInit()
+ {
+ CalculatorPanel.FormBorderStyle = FormBorderStyle.None;
+ CalculatorPanel.BackColor = Color.Gray;
+ CalculatorPanel.TransparencyKey = CalculatorPanel.BackColor;
+ CalculatorPanel.Opacity = 0.90;
+ CalculatorPanel.StartPosition = FormStartPosition.Manual;
+ CalculatorPanel.DesktopLocation = new Point(this.Location.X, this.Location.Y + 30);
+ CalculatorPanel.ClientSize = new Size(this.Size.Width, this.Size.Height - 30);
+ CalculatorPanel.Owner = this;
+ CalculatorPanel.ShowInTaskbar = false;
+
+ CalculatorButton buttonZero = new CalculatorButton("0", new Point(90, 410), CalculatorPanel, equationManager);
+ CalculatorButton buttonOne = new CalculatorButton("1", new Point(20, 360), CalculatorPanel, equationManager);
+ CalculatorButton buttonTwo = new CalculatorButton("2", new Point(90, 360), CalculatorPanel, equationManager);
+ CalculatorButton buttonThree = new CalculatorButton("3", new Point(160, 360), CalculatorPanel, equationManager);
+ CalculatorButton buttonFour = new CalculatorButton("4", new Point(20, 310), CalculatorPanel, equationManager);
+ CalculatorButton buttonFive = new CalculatorButton("5", new Point(90, 310), CalculatorPanel, equationManager);
+ CalculatorButton buttonSix = new CalculatorButton("6", new Point(160, 310), CalculatorPanel, equationManager);
+ CalculatorButton buttonSeven = new CalculatorButton("7", new Point(20, 260), CalculatorPanel, equationManager);
+ CalculatorButton buttonEight = new CalculatorButton("8", new Point(90, 260), CalculatorPanel, equationManager);
+ CalculatorButton buttonNine = new CalculatorButton("9", new Point(160, 260), CalculatorPanel, equationManager);
+
+
+ CalculatorButton buttonLeftBracket = new CalculatorButton("(", new Point(160, 160), CalculatorPanel, equationManager);
+ CalculatorButton buttonRightBracket = new CalculatorButton(")", new Point(230, 160), CalculatorPanel, equationManager);
+
+ CalculatorButton buttonClear = new CalculatorButton("C", new Point(20, 160), CalculatorPanel, equationManager);
+ CalculatorButton buttonClearEverything = new CalculatorButton("CE", new Point(90, 160), CalculatorPanel, equationManager);
+
+ CalculatorButton buttonPowerX = new CalculatorButton("xˣ", new Point(20, 210), CalculatorPanel, equationManager);
+ CalculatorButton buttonPowerTwo = new CalculatorButton("x²", new Point(90, 210), CalculatorPanel, equationManager);
+ CalculatorButton buttonSquareRoot = new CalculatorButton("√", new Point(160, 210), CalculatorPanel, equationManager);
+ CalculatorButton buttonDivide = new CalculatorButton("/", new Point(230, 210), CalculatorPanel, equationManager);
+ CalculatorButton buttonMultiply = new CalculatorButton("*", new Point(230, 260), CalculatorPanel, equationManager);
+ CalculatorButton buttonMinus = new CalculatorButton("-", new Point(230, 310), CalculatorPanel, equationManager);
+ CalculatorButton buttonPlus = new CalculatorButton("+", new Point(230, 360), CalculatorPanel, equationManager);
+ CalculatorButton buttonComma = new CalculatorButton(",", new Point(160, 410), CalculatorPanel, equationManager);
+
+ EqualsButton equalsButton = new EqualsButton(new Point(230, 410), CalculatorPanel, equationManager);
+
+ ToggleTopButton toggleTopButton = new ToggleTopButton(new Point(20, 410), CalculatorPanel);
+ toggleTopButton.Click += ToggleTopButton_Click;
+
+ Label equationTextBox = new Label();
+ equationTextBox.Location = new Point(20, 20);
+ equationTextBox.ClientSize = new Size(260, 80);
+ equationTextBox.TextAlign = ContentAlignment.TopRight;
+ equationTextBox.Font = new Font("Arial", 16);
+ equationTextBox.ForeColor = Color.White;
+ CalculatorPanel.Controls.Add(equationTextBox);
+
+ Label currentOperandTextBox = new Label();
+ currentOperandTextBox.Text = "0";
+ currentOperandTextBox.Location = new Point(20, 100);
+ currentOperandTextBox.ClientSize = new Size(260, 30);
+ currentOperandTextBox.TextAlign = ContentAlignment.TopRight;
+ currentOperandTextBox.Font = new Font("Arial", 20);
+ currentOperandTextBox.ForeColor = Color.White;
+ CalculatorPanel.Controls.Add(currentOperandTextBox);
+
+ equationManager.AcquireOutputLabels(ref equationTextBox, ref currentOperandTextBox);
+
+ CalculatorPanel.Show();
+
+ void ToggleTopButton_Click(object? sender, EventArgs e)
+ {
+ this.Text = this.onTop ? "Calculator" : "Calculator [pinned]";
+ this.onTop = !this.onTop;
+ this.TopMost = !this.TopMost;
+ CalculatorPanel.TopMost = !CalculatorPanel.TopMost;
+ }
+
+
+ }
+
+ private class CalculatorButton : Button
+ {
+ public CalculatorButton(string Text, Point Location, Form Panel, EquationManager equationManager)
+ {
+ this.Text = Text;
+ this.Font = new Font("Arial", 12);
+ this.Location = Location;
+ this.Width = 50;
+ this.Height = 40;
+ this.FlatStyle = FlatStyle.Flat;
+ this.BackColor = LunarGray;
+ this.FlatAppearance.BorderSize = 0;
+ this.FlatAppearance.BorderColor = LunarGray;
+ ForeColor = Color.White;
+ this.Click += equationManager.ProcessButtonInput;
+ Panel.Controls.Add(this);
+ }
+ }
+
+ private class EqualsButton : Button
+ {
+ public EqualsButton(Point Location, Form Panel, EquationManager equationManager)
+ {
+ this.Text = "=";
+ this.Font = new Font("Arial", 12);
+ this.Location = Location;
+ this.Width = 50;
+ this.Height = 40;
+ this.FlatStyle = FlatStyle.Flat;
+ this.BackColor = LunarOrange;
+ this.FlatAppearance.BorderSize = 0;
+ this.FlatAppearance.BorderColor = LunarOrange;
+ ForeColor = Color.White;
+ this.Click += equationManager.EqualsButtonPressed;
+ Panel.Controls.Add(this);
+ }
+ }
+
+ private class ToggleTopButton : Button
+ {
+ public ToggleTopButton(Point Location, Form Panel)
+ {
+ this.Text = "Toggle\ntop";
+ this.Font = new Font("Arial", 7);
+ this.Location = Location;
+ this.Width = 50;
+ this.Height = 40;
+ this.FlatStyle = FlatStyle.Flat;
+ this.BackColor = LunarGray;
+ this.FlatAppearance.BorderSize = 0;
+ this.FlatAppearance.BorderColor = LunarGray;
+ ForeColor = Color.White;
+ Panel.Controls.Add(this);
+ }
+ }
+ }
+}
diff --git a/Evil Calculator/CalculatorBody.resx b/Evil Calculator/CalculatorBody.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/Evil Calculator/CalculatorBody.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Evil Calculator/EquationManager.cs b/Evil Calculator/EquationManager.cs
new file mode 100644
index 0000000..a5c4d09
--- /dev/null
+++ b/Evil Calculator/EquationManager.cs
@@ -0,0 +1,203 @@
+namespace Lunar.Evil_Calculator
+{
+ class EquationManager
+ {
+ private ReverseNotationSolver reverseNotationSolver = new ReverseNotationSolver();
+
+ List equation = new List();
+ string currentOperand = "";
+ Label? outerEquationLabel;
+ Label? outerOperandLabel;
+ int openParentheses;
+
+
+ //NO OPENING PARENTHESES AFTER NUMERICS OR CLOSING PARENTHESES => NULL, OPENING PARENTHESES OR OPERATOR EXPECTED
+ //NO CLOSING PARENTHESES AFTER OPERATORS, EXCEPT IF $currentOperand IS NOT ""
+ //NO CLOSING PARENTHESES WHEN $openParentheses <1
+ //OPERATOR OR null BEFORE OPENING PARENTHESES EXPECTED
+ //$openParentheses SHOULD BE 0 BEFORE SOLVING, DISPLAY ERROR OTHERWISE => HANDLED BY SOLVER
+ //MINUS AFTER OPENING PARENTHESES OR null GOES TO OPERAND IF $currentOperand IS ""
+ //NO OPERATORS AFTER OPERATORS, OPENING PARENTHESES OR null (EXCEPT FOR MINUS THAT GOES TO OPERAND AND SQRT THAT IS UNAR)
+ //NO NUMERICS IF currentOperand.StartsWith("0") AND currentOperand.Length == 1, . ALLOWED-EXPECTED
+ //NO . IF currentOperand.Contains(",")
+
+
+ public void ProcessButtonInput(object? sender, EventArgs e)
+ {
+ Button? buttonPressed = sender as Button;
+ if (buttonPressed != null)
+ {
+
+
+ switch (buttonPressed.Text)
+ {
+ //CLEAR
+ case "C":
+ currentOperand = "";
+ break;
+ case "CE":
+ equation.Clear();
+ currentOperand = "";
+ break;
+ //OPERATORS
+ // + -
+ case "+":
+ if ((!IsOperator() && !IsOpen() && !IsNull()) || currentOperand != "" && currentOperand != "-")
+ {
+ equation.Add(new Token(Token.TokenType.Operand, currentOperand));
+ equation.Add(new Token(Token.TokenType.Operator, buttonPressed.Text, 1));
+ currentOperand = "";
+ }
+ break;
+ case "-":
+ if ((!IsOperator() || currentOperand != "") && currentOperand != "-")
+ {
+ if ((IsOpen() || IsNull()) && currentOperand == "")
+ {
+ currentOperand += "-";
+ }
+ else
+ {
+ equation.Add(new Token(Token.TokenType.Operand, currentOperand));
+ equation.Add(new Token(Token.TokenType.Operator, buttonPressed.Text, 1));
+ currentOperand = "";
+ }
+ }
+ break;
+ // * /
+ case "*" or "/":
+ if ((!IsOperator() && !IsOpen() && !IsNull()) || currentOperand != "" && currentOperand != "-")
+ {
+ equation.Add(new Token(Token.TokenType.Operand, currentOperand));
+ equation.Add(new Token(Token.TokenType.Operator, buttonPressed.Text, 2));
+ currentOperand = "";
+ }
+ break;
+ //SQUARE ROOT
+ case "√":
+ if (!IsClose())
+ {
+ equation.Add(new Token(Token.TokenType.Operand, currentOperand));
+ equation.Add(new Token(Token.TokenType.Operator, buttonPressed.Text, 3));
+ currentOperand = "";
+ }
+ break;
+ //SQUARE AND POWER
+ case "x²":
+ if ((!IsOperator() && !IsOpen() && !IsNull()) || currentOperand != "" && currentOperand != "-")
+ {
+ equation.Add(new Token(Token.TokenType.Operand, currentOperand));
+ equation.Add(new Token(Token.TokenType.Operator, "^", 3));
+ equation.Add(new Token(Token.TokenType.Operand, "2"));
+ currentOperand = "";
+ }
+ break;
+ case "xˣ":
+ if ((!IsOperator() && !IsOpen() && !IsNull()) || currentOperand != "" && currentOperand != "-")
+ {
+ equation.Add(new Token(Token.TokenType.Operand, currentOperand));
+ equation.Add(new Token(Token.TokenType.Operator, "^", 3));
+ currentOperand = "";
+ }
+ break;
+ //PARENTHESES
+ case "(":
+ if (IsOperator() || IsOpen() || IsNull())
+ {
+ equation.Add(new Token(Token.TokenType.Operator, buttonPressed.Text));
+ openParentheses++;
+ currentOperand = "";
+ }
+ break;
+ case ")":
+ if ((!IsOperator() || currentOperand != "") && openParentheses > 0 && currentOperand != "-")
+ {
+ if (currentOperand.Length > 0)
+ {
+ equation.Add(new Token(Token.TokenType.Operand, currentOperand));
+ currentOperand = "";
+ }
+ equation.Add(new Token(Token.TokenType.Operator, buttonPressed.Text));
+ openParentheses--;
+ }
+ break;
+ //POINT
+ case ",":
+ if (currentOperand.Length > 0 && !currentOperand.Contains(","))
+ {
+ currentOperand += buttonPressed.Text;
+ }
+ break;
+ //NUMERIC
+ default:
+ if (!(currentOperand.Length == 1 && currentOperand.StartsWith("0")))
+ {
+ currentOperand += buttonPressed.Text;
+ }
+ break;
+ }
+ UpdateLabels();
+ }
+ }
+
+ public void EqualsButtonPressed(object? sender, EventArgs e)
+ {
+ Button? buttonEquals = sender as Button;
+ if (buttonEquals != null)
+ {
+ if (currentOperand != "") equation.Add(new Token(Token.TokenType.Operand, currentOperand));
+ buttonEquals.Text = "#";
+ this.currentOperand = reverseNotationSolver.Solve(ref equation);
+ UpdateLabels();
+ }
+ }
+
+ public void AcquireOutputLabels(ref Label equationTextBox, ref Label currentOperandTextBox)
+ {
+ this.outerEquationLabel = equationTextBox;
+ this.outerOperandLabel = currentOperandTextBox;
+ }
+
+ public string equationToString()
+ {
+ string equationString = "";
+ foreach (Token token in equation)
+ {
+ equationString += token.value.ToString() + " ";
+ }
+ return equationString;
+ }
+
+ private void UpdateLabels()
+ {
+ if (outerEquationLabel != null && outerOperandLabel != null)
+ {
+ outerEquationLabel.Text = equationToString();
+ outerOperandLabel.Text = currentOperand == "" ? "0" : currentOperand;
+ }
+ }
+
+ private bool IsOperator()
+ {
+ if (equation.Count == 0) return false;
+ return new[] { "+", "-", "*", "/", "^", "√" }.Contains(equation.Last().value);
+ }
+
+ private bool IsOpen()
+ {
+ if (equation.Count == 0) return false;
+ return equation.Last().value == "(";
+ }
+
+ private bool IsClose()
+ {
+ if (equation.Count == 0) return false;
+ return equation.Last().value == ")";
+ }
+
+ private bool IsNull()
+ {
+ return equation.Count == 0;
+ }
+ }
+}
diff --git a/Evil Calculator/Evil Calculator.csproj b/Evil Calculator/Evil Calculator.csproj
new file mode 100644
index 0000000..10c89f1
--- /dev/null
+++ b/Evil Calculator/Evil Calculator.csproj
@@ -0,0 +1,12 @@
+
+
+
+ WinExe
+ net8.0-windows
+ Lunar.Evil_Calculator
+ enable
+ true
+ enable
+
+
+
\ No newline at end of file
diff --git a/Evil Calculator/Program.cs b/Evil Calculator/Program.cs
new file mode 100644
index 0000000..a2842e8
--- /dev/null
+++ b/Evil Calculator/Program.cs
@@ -0,0 +1,12 @@
+namespace Lunar.Evil_Calculator
+{
+ internal static class Program
+ {
+ [STAThread]
+ static void Main()
+ {
+ ApplicationConfiguration.Initialize();
+ Application.Run(new CalculatorBody());
+ }
+ }
+}
\ No newline at end of file
diff --git a/Evil Calculator/ReverseNotattionSolver.cs b/Evil Calculator/ReverseNotattionSolver.cs
new file mode 100644
index 0000000..4cc3d7b
--- /dev/null
+++ b/Evil Calculator/ReverseNotattionSolver.cs
@@ -0,0 +1,116 @@
+namespace Lunar.Evil_Calculator
+{
+ internal class ReverseNotationSolver
+ {
+ List equation = new List();
+
+ public string? ToReverseNotation(ref List equation)
+ {
+ List TEMP = new List();
+ Stack OPERATORS = new Stack();
+ foreach (Token token in equation)
+ {
+ if (token.tokenType == Token.TokenType.Operand)
+ {
+ TEMP.Add(token);
+ }
+ if (token.tokenType == Token.TokenType.Operator)
+ {
+ if (token.value == "(")
+ {
+ OPERATORS.Push(token);
+ }
+ else if (token.value == ")")
+ {
+ while (OPERATORS.Peek().value != "(")
+ {
+ TEMP.Add(OPERATORS.Pop());
+ }
+ OPERATORS.Pop();
+ }
+ else
+ {
+ while (OPERATORS.Count != 0 ? OPERATORS.Peek().priority >= token.priority : false)
+ {
+ TEMP.Add(OPERATORS.Pop());
+ }
+ OPERATORS.Push(token);
+ }
+ }
+ }
+ while (OPERATORS.Count != 0)
+ {
+ TEMP.Add(OPERATORS.Pop());
+ }
+ this.equation = TEMP;
+ return equationToString();
+ }
+
+
+
+ public string? Solve(ref List equation)
+ {
+ ToReverseNotation(ref equation);
+ Stack stack = new Stack();
+ foreach (Token token in this.equation)
+ {
+ double result, left, right;
+ if (token.tokenType == Token.TokenType.Operand)
+ {
+ stack.Push(token);
+ }
+ if (token.tokenType == Token.TokenType.Operator)
+ {
+ switch (token.value)
+ {
+ case "+":
+ right = Convert.ToDouble(stack.Pop().value);
+ left = Convert.ToDouble(stack.Pop().value);
+ result = left + right;
+ stack.Push(new Token(Token.TokenType.Operand, result.ToString()));
+ break;
+ case "-":
+ right = Convert.ToDouble(stack.Pop().value);
+ left = Convert.ToDouble(stack.Pop().value);
+ result = left - right;
+ stack.Push(new Token(Token.TokenType.Operand, result.ToString()));
+ break;
+ case "*":
+ right = Convert.ToDouble(stack.Pop().value);
+ left = Convert.ToDouble(stack.Pop().value);
+ result = left * right;
+ stack.Push(new Token(Token.TokenType.Operand, result.ToString()));
+ break;
+ case "/":
+ right = Convert.ToDouble(stack.Pop().value);
+ left = Convert.ToDouble(stack.Pop().value);
+ result = left / right;
+ stack.Push(new Token(Token.TokenType.Operand, result.ToString()));
+ break;
+ case "^":
+ right = Convert.ToDouble(stack.Pop().value);
+ left = Convert.ToDouble(stack.Pop().value);
+ result = Math.Pow(left, right);
+ stack.Push(new Token(Token.TokenType.Operand, result.ToString()));
+ break;
+ }
+ }
+ }
+ return stack.Pop().value;
+ }
+
+
+
+ public string equationToString()
+ {
+ string equationString = "";
+ foreach (Token token in this.equation)
+ {
+ equationString += token.value.ToString() + " ";
+ }
+ return equationString;
+ }
+
+
+ }
+}
diff --git a/Evil Calculator/Token.cs b/Evil Calculator/Token.cs
new file mode 100644
index 0000000..f5d4af0
--- /dev/null
+++ b/Evil Calculator/Token.cs
@@ -0,0 +1,25 @@
+namespace Lunar.Evil_Calculator
+{
+ internal class Token
+ {
+ public enum TokenType { Operator, Operand };
+ public TokenType tokenType;
+ public string value = "";
+ public int? priority;
+
+ public Token() { }
+
+ public Token(TokenType tokenType, string value)
+ {
+ this.tokenType = tokenType;
+ this.value = value;
+ }
+
+ public Token(TokenType tokenType, string value, int priority)
+ {
+ this.tokenType = tokenType;
+ this.value = value;
+ this.priority = priority;
+ }
+ }
+}
diff --git a/README.md b/README.md
index acf6551..bb46a1c 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,24 @@
-# Evil_Calculator
+# Evil calculator
+I got overdosed on caffeine and made this thing.
+
+## What?
+
+Calculator but evil.
+
+## Why?
+
+Reasons.
+
+## Does it work?
+
+Yes, until it doesn't.
+
+## Unreadable code!
+
+I am clinically insane
+
+
+## License
+
+Perhaps.
\ No newline at end of file