diff --git a/CalculatorApp/CalculatorApp.sln b/CalculatorApp/CalculatorApp.sln
new file mode 100644
index 0000000..e520d68
--- /dev/null
+++ b/CalculatorApp/CalculatorApp.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.4.33403.182
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CalculatorApp", "CalculatorApp\CalculatorApp.csproj", "{31E65DB4-A6C8-4C0F-BB79-2E251A62686D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestsForCalculator", "TestsForCalculator\TestsForCalculator.csproj", "{5F17A030-E207-46F7-88E5-534F89878F08}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {31E65DB4-A6C8-4C0F-BB79-2E251A62686D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {31E65DB4-A6C8-4C0F-BB79-2E251A62686D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {31E65DB4-A6C8-4C0F-BB79-2E251A62686D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {31E65DB4-A6C8-4C0F-BB79-2E251A62686D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5F17A030-E207-46F7-88E5-534F89878F08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5F17A030-E207-46F7-88E5-534F89878F08}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5F17A030-E207-46F7-88E5-534F89878F08}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5F17A030-E207-46F7-88E5-534F89878F08}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {A28D84EF-25A1-486C-AAC0-E0C30FF24335}
+ EndGlobalSection
+EndGlobal
diff --git a/CalculatorApp/CalculatorApp/CalculatorApp.csproj b/CalculatorApp/CalculatorApp/CalculatorApp.csproj
new file mode 100644
index 0000000..e1a0735
--- /dev/null
+++ b/CalculatorApp/CalculatorApp/CalculatorApp.csproj
@@ -0,0 +1,11 @@
+
+
+
+ WinExe
+ net7.0-windows
+ enable
+ true
+ enable
+
+
+
\ No newline at end of file
diff --git a/CalculatorApp/CalculatorApp/CalculatorApp.csproj.user b/CalculatorApp/CalculatorApp/CalculatorApp.csproj.user
new file mode 100644
index 0000000..7814ea2
--- /dev/null
+++ b/CalculatorApp/CalculatorApp/CalculatorApp.csproj.user
@@ -0,0 +1,8 @@
+
+
+
+
+ Form
+
+
+
diff --git a/CalculatorApp/CalculatorApp/Form1.Designer.cs b/CalculatorApp/CalculatorApp/Form1.Designer.cs
new file mode 100644
index 0000000..7d68af7
--- /dev/null
+++ b/CalculatorApp/CalculatorApp/Form1.Designer.cs
@@ -0,0 +1,500 @@
+namespace CalculatorApp
+{
+ partial class Calculator
+ {
+ ///
+ /// 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.SignButton = new System.Windows.Forms.Button();
+ this.ZeroButton = new System.Windows.Forms.Button();
+ this.CommaButton = new System.Windows.Forms.Button();
+ this.EqualButton = new System.Windows.Forms.Button();
+ this.OneButton = new System.Windows.Forms.Button();
+ this.TwoButton = new System.Windows.Forms.Button();
+ this.ThreeButton = new System.Windows.Forms.Button();
+ this.PlusButton = new System.Windows.Forms.Button();
+ this.FourButton = new System.Windows.Forms.Button();
+ this.FiveButton = new System.Windows.Forms.Button();
+ this.SixButton = new System.Windows.Forms.Button();
+ this.SubtractButton = new System.Windows.Forms.Button();
+ this.SevenButton = new System.Windows.Forms.Button();
+ this.EightButton = new System.Windows.Forms.Button();
+ this.NineButton = new System.Windows.Forms.Button();
+ this.MultiplyButton = new System.Windows.Forms.Button();
+ this.SquaringButton = new System.Windows.Forms.Button();
+ this.TakeRootButton = new System.Windows.Forms.Button();
+ this.ResetButton = new System.Windows.Forms.Button();
+ this.DivisionButton = new System.Windows.Forms.Button();
+ this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
+ this.DeleteButton = new System.Windows.Forms.Button();
+ this.ProcentButton = new System.Windows.Forms.Button();
+ this.CEButton = new System.Windows.Forms.Button();
+ this.UnitDividedByNumberButton = new System.Windows.Forms.Button();
+ this.MainOutputLabel = new System.Windows.Forms.Label();
+ this.BackOutputLabel = new System.Windows.Forms.Label();
+ this.ErrorLabel = new System.Windows.Forms.Label();
+ this.tableLayoutPanel1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // SignButton
+ //
+ this.SignButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.SignButton.Location = new System.Drawing.Point(3, 298);
+ this.SignButton.Name = "SignButton";
+ this.SignButton.Size = new System.Drawing.Size(89, 57);
+ this.SignButton.TabIndex = 0;
+ this.SignButton.Text = "+/-";
+ this.SignButton.UseVisualStyleBackColor = true;
+ this.SignButton.Click += new System.EventHandler(this.SignButton_Click);
+ //
+ // ZeroButton
+ //
+ this.ZeroButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.ZeroButton.Location = new System.Drawing.Point(98, 298);
+ this.ZeroButton.Name = "ZeroButton";
+ this.ZeroButton.Size = new System.Drawing.Size(89, 57);
+ this.ZeroButton.TabIndex = 1;
+ this.ZeroButton.Text = "0";
+ this.ZeroButton.UseVisualStyleBackColor = true;
+ this.ZeroButton.Click += new System.EventHandler(this.ZeroButton_Click);
+ //
+ // CommaButton
+ //
+ this.CommaButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.CommaButton.Location = new System.Drawing.Point(193, 298);
+ this.CommaButton.Name = "CommaButton";
+ this.CommaButton.Size = new System.Drawing.Size(89, 57);
+ this.CommaButton.TabIndex = 2;
+ this.CommaButton.Text = ",";
+ this.CommaButton.UseVisualStyleBackColor = true;
+ this.CommaButton.Click += new System.EventHandler(this.CommaButton_Click);
+ //
+ // EqualButton
+ //
+ this.EqualButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.EqualButton.BackColor = System.Drawing.SystemColors.ControlLight;
+ this.EqualButton.Location = new System.Drawing.Point(288, 298);
+ this.EqualButton.Name = "EqualButton";
+ this.EqualButton.Size = new System.Drawing.Size(89, 57);
+ this.EqualButton.TabIndex = 3;
+ this.EqualButton.Text = "=";
+ this.EqualButton.UseVisualStyleBackColor = false;
+ this.EqualButton.Click += new System.EventHandler(this.EqualButton_Click);
+ //
+ // OneButton
+ //
+ this.OneButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.OneButton.Location = new System.Drawing.Point(3, 239);
+ this.OneButton.Name = "OneButton";
+ this.OneButton.Size = new System.Drawing.Size(89, 53);
+ this.OneButton.TabIndex = 4;
+ this.OneButton.Text = "1";
+ this.OneButton.UseVisualStyleBackColor = true;
+ this.OneButton.Click += new System.EventHandler(this.OneButton_Click);
+ //
+ // TwoButton
+ //
+ this.TwoButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.TwoButton.Location = new System.Drawing.Point(98, 239);
+ this.TwoButton.Name = "TwoButton";
+ this.TwoButton.Size = new System.Drawing.Size(89, 53);
+ this.TwoButton.TabIndex = 5;
+ this.TwoButton.Text = "2";
+ this.TwoButton.UseVisualStyleBackColor = true;
+ this.TwoButton.Click += new System.EventHandler(this.TwoButton_Click);
+ //
+ // ThreeButton
+ //
+ this.ThreeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.ThreeButton.Location = new System.Drawing.Point(193, 239);
+ this.ThreeButton.Name = "ThreeButton";
+ this.ThreeButton.Size = new System.Drawing.Size(89, 53);
+ this.ThreeButton.TabIndex = 6;
+ this.ThreeButton.Text = "3";
+ this.ThreeButton.UseVisualStyleBackColor = true;
+ this.ThreeButton.Click += new System.EventHandler(this.ThreeButton_Click);
+ //
+ // PlusButton
+ //
+ this.PlusButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.PlusButton.Location = new System.Drawing.Point(288, 239);
+ this.PlusButton.Name = "PlusButton";
+ this.PlusButton.Size = new System.Drawing.Size(89, 53);
+ this.PlusButton.TabIndex = 7;
+ this.PlusButton.Text = "+";
+ this.PlusButton.UseVisualStyleBackColor = true;
+ this.PlusButton.Click += new System.EventHandler(this.OperationButton_Click);
+ //
+ // FourButton
+ //
+ this.FourButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.FourButton.Location = new System.Drawing.Point(3, 180);
+ this.FourButton.Name = "FourButton";
+ this.FourButton.Size = new System.Drawing.Size(89, 53);
+ this.FourButton.TabIndex = 8;
+ this.FourButton.Text = "4";
+ this.FourButton.UseVisualStyleBackColor = true;
+ this.FourButton.Click += new System.EventHandler(this.FourButton_Click);
+ //
+ // FiveButton
+ //
+ this.FiveButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.FiveButton.Location = new System.Drawing.Point(98, 180);
+ this.FiveButton.Name = "FiveButton";
+ this.FiveButton.Size = new System.Drawing.Size(89, 53);
+ this.FiveButton.TabIndex = 9;
+ this.FiveButton.Text = "5";
+ this.FiveButton.UseVisualStyleBackColor = true;
+ this.FiveButton.Click += new System.EventHandler(this.FiveButton_Click);
+ //
+ // SixButton
+ //
+ this.SixButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.SixButton.Location = new System.Drawing.Point(193, 180);
+ this.SixButton.Name = "SixButton";
+ this.SixButton.Size = new System.Drawing.Size(89, 53);
+ this.SixButton.TabIndex = 10;
+ this.SixButton.Text = "6";
+ this.SixButton.UseVisualStyleBackColor = true;
+ this.SixButton.Click += new System.EventHandler(this.SixButton_Click);
+ //
+ // SubtractButton
+ //
+ this.SubtractButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.SubtractButton.Location = new System.Drawing.Point(288, 180);
+ this.SubtractButton.Name = "SubtractButton";
+ this.SubtractButton.Size = new System.Drawing.Size(89, 53);
+ this.SubtractButton.TabIndex = 11;
+ this.SubtractButton.Text = "-";
+ this.SubtractButton.UseVisualStyleBackColor = true;
+ this.SubtractButton.Click += new System.EventHandler(this.OperationButton_Click);
+ //
+ // SevenButton
+ //
+ this.SevenButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.SevenButton.Location = new System.Drawing.Point(3, 121);
+ this.SevenButton.Name = "SevenButton";
+ this.SevenButton.Size = new System.Drawing.Size(89, 53);
+ this.SevenButton.TabIndex = 12;
+ this.SevenButton.Text = "7";
+ this.SevenButton.UseVisualStyleBackColor = true;
+ this.SevenButton.Click += new System.EventHandler(this.SevenButton_Click);
+ //
+ // EightButton
+ //
+ this.EightButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.EightButton.Location = new System.Drawing.Point(98, 121);
+ this.EightButton.Name = "EightButton";
+ this.EightButton.Size = new System.Drawing.Size(89, 53);
+ this.EightButton.TabIndex = 13;
+ this.EightButton.Text = "8";
+ this.EightButton.UseVisualStyleBackColor = true;
+ this.EightButton.Click += new System.EventHandler(this.EightButton_Click);
+ //
+ // NineButton
+ //
+ this.NineButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.NineButton.Location = new System.Drawing.Point(193, 121);
+ this.NineButton.Name = "NineButton";
+ this.NineButton.Size = new System.Drawing.Size(89, 53);
+ this.NineButton.TabIndex = 14;
+ this.NineButton.Text = "9";
+ this.NineButton.UseVisualStyleBackColor = true;
+ this.NineButton.Click += new System.EventHandler(this.NineButton_Click);
+ //
+ // MultiplyButton
+ //
+ this.MultiplyButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.MultiplyButton.Location = new System.Drawing.Point(288, 121);
+ this.MultiplyButton.Name = "MultiplyButton";
+ this.MultiplyButton.Size = new System.Drawing.Size(89, 53);
+ this.MultiplyButton.TabIndex = 15;
+ this.MultiplyButton.Text = "*";
+ this.MultiplyButton.UseVisualStyleBackColor = true;
+ this.MultiplyButton.Click += new System.EventHandler(this.OperationButton_Click);
+ //
+ // SquaringButton
+ //
+ this.SquaringButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.SquaringButton.Location = new System.Drawing.Point(98, 62);
+ this.SquaringButton.Name = "SquaringButton";
+ this.SquaringButton.Size = new System.Drawing.Size(89, 53);
+ this.SquaringButton.TabIndex = 16;
+ this.SquaringButton.Text = "x^2";
+ this.SquaringButton.UseVisualStyleBackColor = true;
+ this.SquaringButton.Click += new System.EventHandler(this.SquaringButton_Click);
+ //
+ // TakeRootButton
+ //
+ this.TakeRootButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.TakeRootButton.Location = new System.Drawing.Point(193, 62);
+ this.TakeRootButton.Name = "TakeRootButton";
+ this.TakeRootButton.Size = new System.Drawing.Size(89, 53);
+ this.TakeRootButton.TabIndex = 17;
+ this.TakeRootButton.Text = "sqrt(x)";
+ this.TakeRootButton.UseVisualStyleBackColor = true;
+ this.TakeRootButton.Click += new System.EventHandler(this.TakeRootButton_Click);
+ //
+ // ResetButton
+ //
+ this.ResetButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.ResetButton.Location = new System.Drawing.Point(193, 3);
+ this.ResetButton.Name = "ResetButton";
+ this.ResetButton.Size = new System.Drawing.Size(89, 53);
+ this.ResetButton.TabIndex = 18;
+ this.ResetButton.Text = "C";
+ this.ResetButton.UseVisualStyleBackColor = true;
+ this.ResetButton.Click += new System.EventHandler(this.ResetButton_Click);
+ //
+ // DivisionButton
+ //
+ this.DivisionButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.DivisionButton.Location = new System.Drawing.Point(288, 62);
+ this.DivisionButton.Name = "DivisionButton";
+ this.DivisionButton.Size = new System.Drawing.Size(89, 53);
+ this.DivisionButton.TabIndex = 19;
+ this.DivisionButton.Text = "/";
+ this.DivisionButton.UseVisualStyleBackColor = true;
+ this.DivisionButton.Click += new System.EventHandler(this.OperationButton_Click);
+ //
+ // tableLayoutPanel1
+ //
+ this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.tableLayoutPanel1.ColumnCount = 4;
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
+ this.tableLayoutPanel1.Controls.Add(this.ResetButton, 2, 0);
+ this.tableLayoutPanel1.Controls.Add(this.ZeroButton, 1, 5);
+ this.tableLayoutPanel1.Controls.Add(this.SignButton, 0, 5);
+ this.tableLayoutPanel1.Controls.Add(this.CommaButton, 2, 5);
+ this.tableLayoutPanel1.Controls.Add(this.EqualButton, 3, 5);
+ this.tableLayoutPanel1.Controls.Add(this.PlusButton, 3, 4);
+ this.tableLayoutPanel1.Controls.Add(this.SubtractButton, 3, 3);
+ this.tableLayoutPanel1.Controls.Add(this.MultiplyButton, 3, 2);
+ this.tableLayoutPanel1.Controls.Add(this.DivisionButton, 3, 1);
+ this.tableLayoutPanel1.Controls.Add(this.DeleteButton, 3, 0);
+ this.tableLayoutPanel1.Controls.Add(this.ThreeButton, 2, 4);
+ this.tableLayoutPanel1.Controls.Add(this.NineButton, 2, 2);
+ this.tableLayoutPanel1.Controls.Add(this.SixButton, 2, 3);
+ this.tableLayoutPanel1.Controls.Add(this.TwoButton, 1, 4);
+ this.tableLayoutPanel1.Controls.Add(this.FiveButton, 1, 3);
+ this.tableLayoutPanel1.Controls.Add(this.EightButton, 1, 2);
+ this.tableLayoutPanel1.Controls.Add(this.OneButton, 0, 4);
+ this.tableLayoutPanel1.Controls.Add(this.FourButton, 0, 3);
+ this.tableLayoutPanel1.Controls.Add(this.SevenButton, 0, 2);
+ this.tableLayoutPanel1.Controls.Add(this.ProcentButton, 0, 0);
+ this.tableLayoutPanel1.Controls.Add(this.CEButton, 1, 0);
+ this.tableLayoutPanel1.Controls.Add(this.UnitDividedByNumberButton, 0, 1);
+ this.tableLayoutPanel1.Controls.Add(this.TakeRootButton, 2, 1);
+ this.tableLayoutPanel1.Controls.Add(this.SquaringButton, 1, 1);
+ this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 142);
+ this.tableLayoutPanel1.Name = "tableLayoutPanel1";
+ this.tableLayoutPanel1.RowCount = 6;
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.665F));
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.665F));
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.665F));
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.665F));
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.665F));
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.675F));
+ this.tableLayoutPanel1.Size = new System.Drawing.Size(380, 358);
+ this.tableLayoutPanel1.TabIndex = 21;
+ this.tableLayoutPanel1.Paint += new System.Windows.Forms.PaintEventHandler(this.tableLayoutPanel1_Paint);
+ //
+ // DeleteButton
+ //
+ this.DeleteButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.DeleteButton.BackColor = System.Drawing.SystemColors.ControlLight;
+ this.DeleteButton.Location = new System.Drawing.Point(288, 3);
+ this.DeleteButton.Name = "DeleteButton";
+ this.DeleteButton.Size = new System.Drawing.Size(89, 53);
+ this.DeleteButton.TabIndex = 23;
+ this.DeleteButton.Text = "<=";
+ this.DeleteButton.UseVisualStyleBackColor = false;
+ this.DeleteButton.Click += new System.EventHandler(this.DeleteButton_Click);
+ //
+ // ProcentButton
+ //
+ this.ProcentButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.ProcentButton.Location = new System.Drawing.Point(3, 3);
+ this.ProcentButton.Name = "ProcentButton";
+ this.ProcentButton.Size = new System.Drawing.Size(89, 53);
+ this.ProcentButton.TabIndex = 20;
+ this.ProcentButton.Text = "%";
+ this.ProcentButton.UseVisualStyleBackColor = true;
+ this.ProcentButton.Click += new System.EventHandler(this.ProcentButton_Click);
+ //
+ // CEButton
+ //
+ this.CEButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.CEButton.Location = new System.Drawing.Point(98, 3);
+ this.CEButton.Name = "CEButton";
+ this.CEButton.Size = new System.Drawing.Size(89, 53);
+ this.CEButton.TabIndex = 21;
+ this.CEButton.Text = "CE";
+ this.CEButton.UseVisualStyleBackColor = true;
+ this.CEButton.Click += new System.EventHandler(this.CEButton_Click);
+ //
+ // UnitDividedByNumberButton
+ //
+ this.UnitDividedByNumberButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.UnitDividedByNumberButton.Location = new System.Drawing.Point(3, 62);
+ this.UnitDividedByNumberButton.Name = "UnitDividedByNumberButton";
+ this.UnitDividedByNumberButton.Size = new System.Drawing.Size(89, 53);
+ this.UnitDividedByNumberButton.TabIndex = 22;
+ this.UnitDividedByNumberButton.Text = "1/x";
+ this.UnitDividedByNumberButton.UseVisualStyleBackColor = true;
+ this.UnitDividedByNumberButton.Click += new System.EventHandler(this.UnitDividedByNumberButton_Click);
+ //
+ // MainOutputLabel
+ //
+ this.MainOutputLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.MainOutputLabel.Font = new System.Drawing.Font("Segoe UI", 23F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+ this.MainOutputLabel.Location = new System.Drawing.Point(0, 48);
+ this.MainOutputLabel.Name = "MainOutputLabel";
+ this.MainOutputLabel.Size = new System.Drawing.Size(380, 94);
+ this.MainOutputLabel.TabIndex = 22;
+ this.MainOutputLabel.Text = "0";
+ //
+ // BackOutputLabel
+ //
+ this.BackOutputLabel.Font = new System.Drawing.Font("Segoe UI", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+ this.BackOutputLabel.Location = new System.Drawing.Point(221, 3);
+ this.BackOutputLabel.Name = "BackOutputLabel";
+ this.BackOutputLabel.Size = new System.Drawing.Size(159, 45);
+ this.BackOutputLabel.TabIndex = 23;
+ //
+ // ErrorLabel
+ //
+ this.ErrorLabel.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+ this.ErrorLabel.Location = new System.Drawing.Point(3, 3);
+ this.ErrorLabel.Name = "ErrorLabel";
+ this.ErrorLabel.Size = new System.Drawing.Size(212, 45);
+ this.ErrorLabel.TabIndex = 24;
+ //
+ // Calculator
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(382, 503);
+ this.Controls.Add(this.ErrorLabel);
+ this.Controls.Add(this.BackOutputLabel);
+ this.Controls.Add(this.MainOutputLabel);
+ this.Controls.Add(this.tableLayoutPanel1);
+ this.MinimumSize = new System.Drawing.Size(375, 550);
+ this.Name = "Calculator";
+ this.Text = "Calculator";
+ this.Load += new System.EventHandler(this.Form1_Load);
+ this.tableLayoutPanel1.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+
+ #endregion
+
+ private Button SignButton;
+ private Button ZeroButton;
+ private Button CommaButton;
+ private Button EqualButton;
+ private Button OneButton;
+ private Button TwoButton;
+ private Button ThreeButton;
+ private Button PlusButton;
+ private Button FourButton;
+ private Button FiveButton;
+ private Button SixButton;
+ private Button SubtractButton;
+ private Button SevenButton;
+ private Button EightButton;
+ private Button NineButton;
+ private Button MultiplyButton;
+ private Button SquaringButton;
+ private Button TakeRootButton;
+ private Button ResetButton;
+ private Button DivisionButton;
+ private TableLayoutPanel tableLayoutPanel1;
+ private Button DeleteButton;
+ private Button ProcentButton;
+ private Button CEButton;
+ private Button UnitDividedByNumberButton;
+ private Label MainOutputLabel;
+ private Label BackOutputLabel;
+ private Label ErrorLabel;
+ }
+}
\ No newline at end of file
diff --git a/CalculatorApp/CalculatorApp/Form1.cs b/CalculatorApp/CalculatorApp/Form1.cs
new file mode 100644
index 0000000..18654ab
--- /dev/null
+++ b/CalculatorApp/CalculatorApp/Form1.cs
@@ -0,0 +1,260 @@
+namespace CalculatorApp;
+
+public enum ConditionCalculator
+{
+ start,
+ firstNumber,
+ signFirstNumber,
+ operation,
+ secondNumber,
+ signSecondNumber
+}
+
+public partial class Calculator : Form
+{
+
+ TableLayoutPanel tableLayoutPanel;
+ private ConditionCalculator conditionCalculator = ConditionCalculator.start;
+ private string firstNumber = "";
+ private string secondNumber = "";
+
+ public Calculator()
+ {
+ InitializeComponent();
+
+ tableLayoutPanel = new TableLayoutPanel
+ {
+ Parent = this,
+ CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset,
+ AutoSize = true,
+ AutoSizeMode = AutoSizeMode.GrowAndShrink
+ };
+ }
+
+ private void Form1_Load(object sender, EventArgs e) {}
+
+ private bool IsInfinity()
+ {
+ if (firstNumber == "∞" || firstNumber == "-∞" || secondNumber == "∞" || secondNumber == "-∞")
+ {
+ ErrorLabel.Text = "Error";
+ firstNumber = "";
+ secondNumber = "";
+ MainOutputLabel.Text = "0";
+ BackOutputLabel.Text = "";
+ conditionCalculator = ConditionCalculator.start;
+ return true;
+ }
+ return false;
+ }
+
+ private void SignButton_Click(object sender, EventArgs e)
+ {
+ if (IsInfinity())
+ {
+ return;
+ }
+ ErrorLabel.Text = "";
+ var functional = new Functional();
+ functional.SignButtonClick(ref conditionCalculator, ref firstNumber, ref secondNumber, ref MainOutputLabel, false);
+ }
+
+ private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e) {}
+
+
+ private void DeleteButton_Click(object sender, EventArgs e)
+ {
+ if (IsInfinity())
+ {
+ return;
+ }
+ ErrorLabel.Text = "";
+ var functional = new Functional();
+ functional.DeleteButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref MainOutputLabel, false);
+ }
+
+ private void CommaButton_Click(object sender, EventArgs e)
+ {
+ if (IsInfinity())
+ {
+ return;
+ }
+ ErrorLabel.Text = "";
+ var functional = new Functional();
+ functional.CommaButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref MainOutputLabel, false);
+ }
+
+ private void ResetButton_Click(object sender, EventArgs e)
+ {
+ var functional = new Functional();
+ functional.ResetButton(ref conditionCalculator, ref firstNumber,
+ ref secondNumber, ref MainOutputLabel, ref BackOutputLabel,
+ ref ErrorLabel, false);
+ }
+
+ private void CEButton_Click(object sender, EventArgs e)
+ {
+ if (IsInfinity())
+ {
+ return;
+ }
+ ErrorLabel.Text = "";
+ var functional = new Functional();
+ functional.CEButton(ref conditionCalculator, ref firstNumber,
+ ref secondNumber, ref MainOutputLabel, false);
+ }
+
+ private void WorkWithOperations(char symbol)
+ {
+ if (IsInfinity())
+ {
+ return;
+ }
+ ErrorLabel.Text = "";
+ var functional = new Functional();
+ functional.WorkWithOperations(ref conditionCalculator, ref firstNumber,
+ ref secondNumber, ref MainOutputLabel, ref BackOutputLabel,
+ ref ErrorLabel, false, symbol);
+ }
+
+ private void OperationButton_Click(object sender, EventArgs e)
+ {
+ WorkWithOperations((sender as Button)?.Text[0] ?? throw new Exception());
+ }
+
+ private void EqualButton_Click(object sender, EventArgs e)
+ {
+ if (IsInfinity())
+ {
+ return;
+ }
+ ErrorLabel.Text = "";
+ var functional = new Functional();
+ functional.EqualButton(ref conditionCalculator, ref firstNumber,
+ ref secondNumber, ref MainOutputLabel, ref BackOutputLabel,
+ ref ErrorLabel, false);
+ }
+
+ private void WorkWithNumbers(char number)
+ {
+ if (IsInfinity())
+ {
+ return;
+ }
+ ErrorLabel.Text = "";
+ var functional = new Functional();
+ functional.WorkWithNumber(ref conditionCalculator, ref firstNumber,
+ ref secondNumber, ref MainOutputLabel,
+ false, number);
+ }
+
+ private void OneButton_Click(object sender, EventArgs e)
+ {
+ WorkWithNumbers('1');
+ }
+
+ private void TwoButton_Click(object sender, EventArgs e)
+ {
+ WorkWithNumbers('2');
+ }
+
+ private void ThreeButton_Click(object sender, EventArgs e)
+ {
+ WorkWithNumbers('3');
+ }
+
+ private void FourButton_Click(object sender, EventArgs e)
+ {
+ WorkWithNumbers('4');
+ }
+
+ private void FiveButton_Click(object sender, EventArgs e)
+ {
+ WorkWithNumbers('5');
+ }
+
+ private void SixButton_Click(object sender, EventArgs e)
+ {
+ WorkWithNumbers('6');
+ }
+
+ private void SevenButton_Click(object sender, EventArgs e)
+ {
+ WorkWithNumbers('7');
+ }
+
+ private void EightButton_Click(object sender, EventArgs e)
+ {
+ WorkWithNumbers('8');
+ }
+
+ private void NineButton_Click(object sender, EventArgs e)
+ {
+ WorkWithNumbers('9');
+ }
+
+ private void ZeroButton_Click(object sender, EventArgs e)
+ {
+ if (IsInfinity())
+ {
+ return;
+ }
+ ErrorLabel.Text = "";
+ var functional = new Functional();
+ functional.ZeroButton(ref conditionCalculator, ref firstNumber,
+ ref secondNumber, ref MainOutputLabel,
+ false);
+ }
+ private void ProcentButton_Click(object sender, EventArgs e)
+ {
+ if (IsInfinity())
+ {
+ return;
+ }
+ ErrorLabel.Text = "";
+ var functional = new Functional();
+ functional.ProcentButton(ref conditionCalculator, ref firstNumber,
+ ref secondNumber, ref MainOutputLabel,
+ false);
+ }
+
+ private void SquaringButton_Click(object sender, EventArgs e)
+ {
+ if (IsInfinity())
+ {
+ return;
+ }
+ ErrorLabel.Text = "";
+ ErrorLabel.Text = "";
+ var functional = new Functional();
+ functional.SquaringButton(ref conditionCalculator, ref firstNumber,
+ ref secondNumber, ref MainOutputLabel,
+ false);
+ }
+
+ private void TakeRootButton_Click(object sender, EventArgs e)
+ {
+ if (IsInfinity())
+ {
+ return;
+ }
+ ErrorLabel.Text = "";
+ var functional = new Functional();
+ functional.TakeRootButton(ref conditionCalculator, ref firstNumber,
+ ref secondNumber, ref MainOutputLabel, ref BackOutputLabel,
+ ref ErrorLabel, false);
+ }
+
+ private void UnitDividedByNumberButton_Click(object sender, EventArgs e)
+ {
+ if (IsInfinity())
+ {
+ return;
+ }
+ ErrorLabel.Text = "";
+ var functional = new Functional();
+ functional.UnitDividedByNumberButton(ref conditionCalculator, ref firstNumber,
+ ref secondNumber, ref MainOutputLabel, ref BackOutputLabel,
+ ref ErrorLabel, false);
+ }
+}
\ No newline at end of file
diff --git a/CalculatorApp/CalculatorApp/Form1.resx b/CalculatorApp/CalculatorApp/Form1.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/CalculatorApp/CalculatorApp/Form1.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/CalculatorApp/CalculatorApp/Functional.cs b/CalculatorApp/CalculatorApp/Functional.cs
new file mode 100644
index 0000000..4772a80
--- /dev/null
+++ b/CalculatorApp/CalculatorApp/Functional.cs
@@ -0,0 +1,781 @@
+namespace CalculatorApp;
+
+public class Functional
+{
+ private void ChangeLabel(ref Label label, bool isTest, string stringToLabel)
+ {
+ if (!isTest)
+ {
+ label.Text = stringToLabel;
+ }
+ }
+
+ ///
+ /// Button for change sign number
+ ///
+ /// Main screen of elements
+ /// Checking what the launch is for
+ public void SignButtonClick(ref ConditionCalculator conditionCalculator, ref string firstNumber, ref string secondNumber, ref Label MainOutputLabel, bool isTest)
+ {
+ switch (conditionCalculator)
+ {
+ case ConditionCalculator.start:
+ break;
+ case ConditionCalculator.firstNumber:
+ if (!(firstNumber != "" && firstNumber.Length == 1 && firstNumber[0] == '0'))
+ {
+ firstNumber = firstNumber.Insert(0, "-");
+ ChangeLabel(ref MainOutputLabel, isTest, firstNumber);
+ conditionCalculator = ConditionCalculator.signFirstNumber;
+ }
+ break;
+ case ConditionCalculator.signFirstNumber:
+ if (firstNumber[0] != '-')
+ {
+ firstNumber = firstNumber.Insert(0, "-");
+ }
+ else
+ {
+ firstNumber = firstNumber.Substring(1);
+ }
+ ChangeLabel(ref MainOutputLabel, isTest, firstNumber);
+ break;
+ case ConditionCalculator.operation:
+ if (firstNumber[0] != '-')
+ {
+ secondNumber = firstNumber.Insert(0, "-");
+ }
+ else
+ {
+ secondNumber = firstNumber.Substring(1);
+ }
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ conditionCalculator = ConditionCalculator.signSecondNumber;
+ break;
+ case ConditionCalculator.secondNumber:
+ if (!(secondNumber != "" && secondNumber.Length == 1 && secondNumber[0] == '0'))
+ {
+ if (secondNumber[0] != '-')
+ {
+ secondNumber = secondNumber.Insert(0, "-");
+ }
+ else
+ {
+ secondNumber = secondNumber.Substring(1);
+ }
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ conditionCalculator = ConditionCalculator.signSecondNumber;
+ }
+ break;
+ case ConditionCalculator.signSecondNumber:
+ if (secondNumber[0] != '-')
+ {
+ secondNumber = secondNumber.Insert(0, "-");
+ }
+ else
+ {
+ secondNumber = secondNumber.Substring(1);
+ }
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ break;
+ }
+ }
+
+ ///
+ /// Button for deletions symbols
+ ///
+ /// Main screen of elements
+ /// Checking what the launch is for
+ public void DeleteButton(ref ConditionCalculator conditionCalculator, ref string firstNumber, ref string secondNumber, ref Label MainOutputLabel, bool isTest)
+ {
+ switch (conditionCalculator)
+ {
+ case ConditionCalculator.start:
+ break;
+ case ConditionCalculator.firstNumber:
+ firstNumber = firstNumber.Remove(firstNumber.Length - 1);
+ if (firstNumber.Length == 0)
+ {
+ conditionCalculator = ConditionCalculator.start;
+ ChangeLabel(ref MainOutputLabel, isTest, "0");
+ }
+ else
+ {
+ ChangeLabel(ref MainOutputLabel, isTest, firstNumber);
+ }
+ break;
+ case ConditionCalculator.signFirstNumber:
+ firstNumber = firstNumber.Remove(firstNumber.Length - 1);
+ if (firstNumber.Length == 0 || (firstNumber.Length == 1 && firstNumber[0] == '-'))
+ {
+ firstNumber = "";
+ conditionCalculator = ConditionCalculator.start;
+ ChangeLabel(ref MainOutputLabel, isTest, "0");
+ }
+ else
+ {
+ ChangeLabel(ref MainOutputLabel, isTest, firstNumber);
+ }
+ break;
+ case ConditionCalculator.operation:
+ break;
+ case ConditionCalculator.secondNumber:
+ secondNumber = secondNumber.Remove(secondNumber.Length - 1);
+ if (secondNumber.Length == 0)
+ {
+ conditionCalculator = ConditionCalculator.operation;
+ ChangeLabel(ref MainOutputLabel, isTest, "0");
+ }
+ else
+ {
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ }
+ break;
+ case ConditionCalculator.signSecondNumber:
+ secondNumber = secondNumber.Remove(secondNumber.Length - 1);
+ if (secondNumber.Length == 0 || (secondNumber.Length == 1 && secondNumber[0] == '-'))
+ {
+ conditionCalculator = ConditionCalculator.operation;
+ ChangeLabel(ref MainOutputLabel, isTest, "0");
+ }
+ else
+ {
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ }
+ break;
+ }
+ }
+
+ ///
+ /// Button for add comma
+ ///
+ /// Main screen of elements
+ /// Checking what the launch is for
+ public void CommaButton(ref ConditionCalculator conditionCalculator, ref string firstNumber, ref string secondNumber, ref Label MainOutputLabel, bool isTest)
+ {
+ switch (conditionCalculator)
+ {
+ case ConditionCalculator.start:
+ firstNumber += "0,";
+ ChangeLabel(ref MainOutputLabel, isTest, MainOutputLabel.Text + ',');
+ conditionCalculator = ConditionCalculator.firstNumber;
+ break;
+ case ConditionCalculator.firstNumber:
+ if (!firstNumber.Contains(','))
+ {
+ if (firstNumber.Length == 0)
+ {
+ firstNumber += '0';
+ }
+ firstNumber += ',';
+ ChangeLabel(ref MainOutputLabel, isTest, MainOutputLabel.Text + ',');
+ }
+ break;
+ case ConditionCalculator.signFirstNumber:
+ if (!firstNumber.Contains(','))
+ {
+ firstNumber += ',';
+ ChangeLabel(ref MainOutputLabel, isTest, MainOutputLabel.Text + ',');
+ }
+ break;
+ case ConditionCalculator.operation:
+ secondNumber = "0,";
+ ChangeLabel(ref MainOutputLabel, isTest, MainOutputLabel.Text + "0,");
+ conditionCalculator = ConditionCalculator.secondNumber;
+ break;
+ case ConditionCalculator.secondNumber:
+ if (!secondNumber.Contains(','))
+ {
+ secondNumber += ',';
+ ChangeLabel(ref MainOutputLabel, isTest, MainOutputLabel.Text + ',');
+ }
+ break;
+ case ConditionCalculator.signSecondNumber:
+ if (!secondNumber.Contains(','))
+ {
+ secondNumber += ',';
+ ChangeLabel(ref MainOutputLabel, isTest, MainOutputLabel.Text + ',');
+ }
+ break;
+ }
+ }
+
+ ///
+ /// Button for reset calculator
+ ///
+ /// Main screen of elements
+ /// Checking what the launch is for
+ /// Back screen of elements
+ /// Screen behind Main screen for error messages
+ public void ResetButton(ref ConditionCalculator conditionCalculator, ref string firstNumber,
+ ref string secondNumber, ref Label MainOutputLabel, ref Label BackOutputLabel,
+ ref Label ErrorLabel, bool isTest)
+ {
+ if (!isTest)
+ {
+ MainOutputLabel.Text = "0";
+ BackOutputLabel.Text = "";
+ firstNumber = "";
+ secondNumber = "";
+ ErrorLabel.Text = "";
+ }
+ conditionCalculator = ConditionCalculator.start;
+ }
+
+ ///
+ /// Button for delete part of expression
+ ///
+ /// Main screen of elements
+ /// Checking what the launch is for
+ public void CEButton(ref ConditionCalculator conditionCalculator, ref string firstNumber,
+ ref string secondNumber, ref Label MainOutputLabel, bool isTest)
+ {
+ ChangeLabel(ref MainOutputLabel, isTest, "0");
+ switch (conditionCalculator)
+ {
+ case ConditionCalculator.start:
+ break;
+ case ConditionCalculator.firstNumber:
+ firstNumber = "";
+ conditionCalculator = ConditionCalculator.start;
+ break;
+ case ConditionCalculator.signFirstNumber:
+ firstNumber = "";
+ conditionCalculator = ConditionCalculator.start;
+ break;
+ case ConditionCalculator.operation:
+ break;
+ case ConditionCalculator.secondNumber:
+ secondNumber = "";
+ conditionCalculator = ConditionCalculator.operation;
+ break;
+ case ConditionCalculator.signSecondNumber:
+ secondNumber = "";
+ conditionCalculator = ConditionCalculator.operation;
+ break;
+ }
+ }
+
+ ///
+ /// Button for division a unit by number
+ ///
+ /// Main screen of elements
+ /// Checking what the launch is for
+ /// Back screen of elements
+ /// Screen behind Main screen for error messages
+ public void UnitDividedByNumberButton(ref ConditionCalculator conditionCalculator, ref string firstNumber,
+ ref string secondNumber, ref Label MainOutputLabel, ref Label BackOutputLabel,
+ ref Label ErrorLabel ,bool isTest)
+ {
+ double firstNumberDouble = 0;
+ double secondNumberDouble = 0;
+ double result = 0;
+ switch (conditionCalculator)
+ {
+ case ConditionCalculator.start:
+ ChangeLabel(ref ErrorLabel, isTest, "Error");
+ conditionCalculator = ConditionCalculator.start;
+ break;
+ case ConditionCalculator.firstNumber:
+ firstNumberDouble = Convert.ToDouble(firstNumber);
+ if (firstNumberDouble == 0)
+ {
+ firstNumber = "";
+ ChangeLabel(ref MainOutputLabel, isTest, "0");
+ ChangeLabel(ref ErrorLabel, isTest, "Error");
+ conditionCalculator = ConditionCalculator.start;
+ return;
+ }
+ result = 1 / firstNumberDouble;
+ firstNumber = result.ToString();
+ ChangeLabel(ref MainOutputLabel, isTest, firstNumber);
+ break;
+ case ConditionCalculator.signFirstNumber:
+ firstNumberDouble = Convert.ToDouble(firstNumber);
+ if (firstNumberDouble == 0)
+ {
+ ChangeLabel(ref MainOutputLabel, isTest, "0");
+ firstNumber = "";
+ ChangeLabel(ref ErrorLabel, isTest, "Error");
+ conditionCalculator = ConditionCalculator.start;
+ return;
+ }
+ result = 1 / firstNumberDouble;
+ firstNumber = result.ToString();
+ ChangeLabel(ref MainOutputLabel, isTest, firstNumber);
+ break;
+ case ConditionCalculator.operation:
+ firstNumberDouble = Convert.ToDouble(firstNumber);
+ if (firstNumberDouble == 0)
+ {
+ ChangeLabel(ref MainOutputLabel, isTest, "0");
+ ChangeLabel(ref BackOutputLabel, isTest, "");
+ firstNumber = "";
+ ChangeLabel(ref ErrorLabel, isTest, "Error");
+ conditionCalculator = ConditionCalculator.start;
+ return;
+ }
+ result = 1 / firstNumberDouble;
+ secondNumber = result.ToString();
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ conditionCalculator = ConditionCalculator.secondNumber;
+ break;
+ case ConditionCalculator.secondNumber:
+ secondNumberDouble = Convert.ToDouble(secondNumber);
+ if (secondNumberDouble == 0)
+ {
+ ChangeLabel(ref MainOutputLabel, isTest, "0");
+ ChangeLabel(ref BackOutputLabel, isTest, "");
+ firstNumber = "";
+ secondNumber = "";
+ ChangeLabel(ref ErrorLabel, isTest, "Error");
+ conditionCalculator = ConditionCalculator.start;
+ return;
+ }
+ result = 1 / secondNumberDouble;
+ secondNumber = result.ToString();
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ break;
+ case ConditionCalculator.signSecondNumber:
+ secondNumberDouble = Convert.ToDouble(secondNumber);
+ if (secondNumberDouble == 0)
+ {
+ ChangeLabel(ref MainOutputLabel, isTest, "0");
+ ChangeLabel(ref BackOutputLabel, isTest, "");
+ firstNumber = "";
+ secondNumber = "";
+ ChangeLabel(ref ErrorLabel, isTest, "Error");
+ conditionCalculator = ConditionCalculator.start;
+ return;
+ }
+ result = 1 / secondNumberDouble;
+ secondNumber = result.ToString();
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ break;
+ }
+ }
+
+ ///
+ /// Take root number
+ ///
+ /// Main screen of elements
+ /// Checking what the launch is for
+ /// Back screen of elements
+ /// Screen behind Main screen for error messages
+ public void TakeRootButton(ref ConditionCalculator conditionCalculator, ref string firstNumber,
+ ref string secondNumber, ref Label MainOutputLabel, ref Label BackOutputLabel,
+ ref Label ErrorLabel, bool isTest)
+ {
+ double firstNumberDouble = 0;
+ double secondNumberDouble = 0;
+ double result = 0;
+ switch (conditionCalculator)
+ {
+ case ConditionCalculator.start:
+ firstNumber = "0";
+ conditionCalculator = ConditionCalculator.firstNumber;
+ break;
+ case ConditionCalculator.firstNumber:
+ firstNumberDouble = Convert.ToDouble(firstNumber);
+ result = Math.Sqrt(firstNumberDouble);
+ firstNumber = result.ToString();
+ ChangeLabel(ref MainOutputLabel, isTest, firstNumber);
+ break;
+ case ConditionCalculator.signFirstNumber:
+ firstNumberDouble = Convert.ToDouble(firstNumber);
+ if (firstNumberDouble < 0)
+ {
+ ChangeLabel(ref MainOutputLabel, isTest, "0");
+ firstNumber = "";
+ ChangeLabel(ref ErrorLabel, isTest, "Error");
+ conditionCalculator = ConditionCalculator.start;
+ return;
+ }
+ result = Math.Sqrt(firstNumberDouble);
+ firstNumber = result.ToString();
+ ChangeLabel(ref MainOutputLabel, isTest, firstNumber);
+ break;
+ case ConditionCalculator.operation:
+ firstNumberDouble = Convert.ToDouble(firstNumber);
+ if (firstNumberDouble < 0)
+ {
+ ChangeLabel(ref MainOutputLabel, isTest, "0");
+ firstNumber = "";
+ ChangeLabel(ref ErrorLabel, isTest, "Error");
+ conditionCalculator = ConditionCalculator.start;
+ return;
+ }
+ result = Math.Sqrt(firstNumberDouble);
+ secondNumber = result.ToString();
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ conditionCalculator = ConditionCalculator.secondNumber;
+ break;
+ case ConditionCalculator.secondNumber:
+ secondNumberDouble = Convert.ToDouble(secondNumber);
+ result = Math.Sqrt(secondNumberDouble);
+ secondNumber = result.ToString();
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ break;
+ case ConditionCalculator.signSecondNumber:
+ secondNumberDouble = Convert.ToDouble(secondNumber);
+ if (secondNumberDouble < 0)
+ {
+ ChangeLabel(ref MainOutputLabel, isTest, "0");
+ ChangeLabel(ref BackOutputLabel, isTest, "");
+ firstNumber = "";
+ secondNumber = "";
+ ChangeLabel(ref ErrorLabel, isTest, "Error");
+ conditionCalculator = ConditionCalculator.start;
+ return;
+ }
+ result = Math.Sqrt(secondNumberDouble);
+ secondNumber = result.ToString();
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ break;
+ }
+ }
+
+ ///
+ /// Squaring number
+ ///
+ /// Main screen of elements
+ /// Checking what the launch is for
+ public void SquaringButton(ref ConditionCalculator conditionCalculator, ref string firstNumber,
+ ref string secondNumber, ref Label MainOutputLabel,
+ bool isTest)
+ {
+ double firstNumberDouble = 0;
+ double secondNumberDouble = 0;
+ double result = 0;
+ switch (conditionCalculator)
+ {
+ case ConditionCalculator.start:
+ firstNumber = "0";
+ conditionCalculator = ConditionCalculator.operation;
+ break;
+ case ConditionCalculator.firstNumber:
+ firstNumberDouble = Convert.ToDouble(firstNumber);
+ result = firstNumberDouble * firstNumberDouble;
+ firstNumber = result.ToString();
+ ChangeLabel(ref MainOutputLabel, isTest, firstNumber);
+ break;
+ case ConditionCalculator.signFirstNumber:
+ firstNumberDouble = Convert.ToDouble(firstNumber);
+ result = firstNumberDouble * firstNumberDouble;
+ firstNumber = result.ToString();
+ ChangeLabel(ref MainOutputLabel, isTest, firstNumber);
+ break;
+ case ConditionCalculator.operation:
+ firstNumberDouble = Convert.ToDouble(firstNumber);
+ result = firstNumberDouble * firstNumberDouble;
+ secondNumber = result.ToString();
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ conditionCalculator = ConditionCalculator.secondNumber;
+ break;
+ case ConditionCalculator.secondNumber:
+ secondNumberDouble = Convert.ToDouble(secondNumber);
+ result = secondNumberDouble * secondNumberDouble;
+ secondNumber = result.ToString();
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ break;
+ case ConditionCalculator.signSecondNumber:
+ secondNumberDouble = Convert.ToDouble(secondNumber);
+ result = secondNumberDouble * secondNumberDouble;
+ secondNumber = result.ToString();
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ break;
+ }
+ }
+
+ ///
+ /// Take procent number
+ ///
+ /// Main screen of elements
+ /// Checking what the launch is for
+ public void ProcentButton(ref ConditionCalculator conditionCalculator, ref string firstNumber,
+ ref string secondNumber, ref Label MainOutputLabel,
+ bool isTest)
+ {
+ double firstNumberDouble = 0;
+ double secondNumberDouble = 0;
+ switch (conditionCalculator)
+ {
+ case ConditionCalculator.start:
+ firstNumber = "0";
+ conditionCalculator = ConditionCalculator.firstNumber;
+ break;
+ case ConditionCalculator.firstNumber:
+ ChangeLabel(ref MainOutputLabel, isTest, "0");
+ firstNumber = "0";
+ break;
+ case ConditionCalculator.signFirstNumber:
+ ChangeLabel(ref MainOutputLabel, isTest, "0");
+ firstNumber = "0";
+ conditionCalculator = ConditionCalculator.firstNumber;
+ break;
+ case ConditionCalculator.operation:
+ firstNumberDouble = Convert.ToDouble(firstNumber);
+ secondNumber = (firstNumberDouble * firstNumberDouble / 100).ToString();
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ conditionCalculator = ConditionCalculator.secondNumber;
+ break;
+ case ConditionCalculator.secondNumber:
+ firstNumberDouble = Convert.ToDouble(firstNumber);
+ secondNumberDouble = Convert.ToDouble(secondNumber);
+ secondNumber = (firstNumberDouble * secondNumberDouble / 100).ToString();
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ break;
+ case ConditionCalculator.signSecondNumber:
+ firstNumberDouble = Convert.ToDouble(firstNumber);
+ secondNumberDouble = Convert.ToDouble(secondNumber);
+ secondNumber = (firstNumberDouble * secondNumberDouble / 100).ToString();
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ break;
+ }
+ }
+
+ ///
+ /// Work with zerro button click
+ ///
+ /// Main screen of elements
+ /// Checking what the launch is for
+ public void ZeroButton(ref ConditionCalculator conditionCalculator, ref string firstNumber,
+ ref string secondNumber, ref Label MainOutputLabel,
+ bool isTest)
+ {
+ switch (conditionCalculator)
+ {
+ case ConditionCalculator.start:
+ firstNumber += '0';
+ conditionCalculator = ConditionCalculator.firstNumber;
+ break;
+ case ConditionCalculator.firstNumber:
+ if (firstNumber.Contains(',') || firstNumber[0] != '0')
+ {
+ firstNumber += '0';
+ ChangeLabel(ref MainOutputLabel, isTest, MainOutputLabel.Text + '0');
+ }
+ break;
+ case ConditionCalculator.signFirstNumber:
+ firstNumber += '0';
+ ChangeLabel(ref MainOutputLabel, isTest, MainOutputLabel.Text + '0');
+ break;
+ case ConditionCalculator.operation:
+ secondNumber = "0";
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ conditionCalculator = ConditionCalculator.secondNumber;
+ break;
+ case ConditionCalculator.secondNumber:
+ if (secondNumber != "" && (secondNumber[0] != '0' || secondNumber.Contains(',')))
+ {
+ secondNumber += '0';
+ ChangeLabel(ref MainOutputLabel, isTest, MainOutputLabel.Text + '0');
+ }
+ break;
+ case ConditionCalculator.signSecondNumber:
+ secondNumber += '0';
+ ChangeLabel(ref MainOutputLabel, isTest, MainOutputLabel.Text + '0');
+ break;
+ }
+ }
+
+ ///
+ /// Work with numbers
+ ///
+ /// Main screen of elements
+ /// Checking what the launch is for
+ /// Pressed number
+ public void WorkWithNumber(ref ConditionCalculator conditionCalculator, ref string firstNumber,
+ ref string secondNumber, ref Label MainOutputLabel,
+ bool isTest, char number)
+ {
+ switch (conditionCalculator)
+ {
+ case ConditionCalculator.start:
+ firstNumber += number;
+ ChangeLabel(ref MainOutputLabel, isTest, firstNumber);
+ conditionCalculator = ConditionCalculator.firstNumber;
+ break;
+ case ConditionCalculator.firstNumber:
+ if (firstNumber[0] == '0' && !firstNumber.Contains(','))
+ {
+ firstNumber = "" + number;
+ }
+ else
+ {
+ firstNumber += number;
+ }
+ ChangeLabel(ref MainOutputLabel, isTest, firstNumber);
+ break;
+ case ConditionCalculator.signFirstNumber:
+ firstNumber += number;
+ ChangeLabel(ref MainOutputLabel, isTest, MainOutputLabel.Text + number);
+ break;
+ case ConditionCalculator.operation:
+ secondNumber = "" + number;
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ conditionCalculator = ConditionCalculator.secondNumber;
+ break;
+ case ConditionCalculator.secondNumber:
+ if (secondNumber[0] == '0' && !secondNumber.Contains(","))
+ {
+ secondNumber = "" + number;
+ }
+ else
+ {
+ secondNumber += number;
+ }
+ ChangeLabel(ref MainOutputLabel, isTest, secondNumber);
+ break;
+ case ConditionCalculator.signSecondNumber:
+ secondNumber += number;
+ ChangeLabel(ref MainOutputLabel, isTest, MainOutputLabel.Text + number);
+ break;
+ }
+ }
+
+ private double NumbersWithOperation(char symbol, string firstNumber, string secondNumber)
+ {
+ double firstNumberDouble = 0;
+ double secondNumberDouble = 0;
+ try
+ {
+ firstNumberDouble = Convert.ToDouble(firstNumber);
+ secondNumberDouble = Convert.ToDouble(secondNumber);
+ }
+ catch (OverflowException)
+ {
+ firstNumber = "";
+ secondNumber = "";
+ return 0;
+ }
+ switch (symbol)
+ {
+ case '+':
+ return firstNumberDouble + secondNumberDouble;
+ case '-':
+ return firstNumberDouble - secondNumberDouble;
+ case '*':
+ return firstNumberDouble * secondNumberDouble;
+ case '/':
+ return firstNumberDouble / secondNumberDouble;
+ }
+ return 0;
+ }
+
+ ///
+ /// Work with pressed equal button
+ ///
+ /// Main screen of elements
+ /// Checking what the launch is for
+ /// Back screen of elements
+ /// Screen behind Main screen for error messages
+ public void EqualButton(ref ConditionCalculator conditionCalculator, ref string firstNumber,
+ ref string secondNumber, ref Label MainOutputLabel, ref Label BackOutputLabel,
+ ref Label ErrorLabel, bool isTest)
+ {
+ if (conditionCalculator == ConditionCalculator.operation
+ || conditionCalculator == ConditionCalculator.secondNumber
+ || conditionCalculator == ConditionCalculator.signSecondNumber)
+ {
+ var operation = BackOutputLabel.Text;
+ if (secondNumber == "")
+ {
+ secondNumber = firstNumber;
+ }
+ firstNumber = NumbersWithOperation(operation[operation.Length - 1], firstNumber, secondNumber).ToString();
+ if (firstNumber == "" || firstNumber == "∞" || firstNumber == "-∞" || firstNumber == "не число")
+ {
+ ChangeLabel(ref MainOutputLabel, isTest, "0");
+ ChangeLabel(ref BackOutputLabel, isTest, "");
+ firstNumber = "";
+ secondNumber = "";
+ ChangeLabel(ref ErrorLabel, isTest, "Error");
+ conditionCalculator = ConditionCalculator.start;
+ }
+ else
+ {
+ ChangeLabel(ref BackOutputLabel, isTest, firstNumber + operation[operation.Length - 1]);
+ conditionCalculator = ConditionCalculator.operation;
+ }
+ }
+ }
+
+ private bool AStringOfZeros(string number)
+ {
+ return !number.Contains('1')
+ && !number.Contains('2')
+ && !number.Contains('3')
+ && !number.Contains('4')
+ && !number.Contains('5')
+ && !number.Contains('6')
+ && !number.Contains('7')
+ && !number.Contains('8')
+ && !number.Contains('9');
+ }
+
+ ///
+ /// Work with pressed operation
+ ///
+ /// Main screen of elements
+ /// Checking what the launch is for
+ /// Back screen of elements
+ /// Screen behind Main screen for error messages
+ /// Pressed operation
+ public void WorkWithOperations(ref ConditionCalculator conditionCalculator, ref string firstNumber,
+ ref string secondNumber, ref Label MainOutputLabel, ref Label BackOutputLabel,
+ ref Label ErrorLabel, bool isTest, char symbol)
+ {
+ switch (conditionCalculator)
+ {
+ case ConditionCalculator.start:
+ firstNumber += '0';
+ ChangeLabel(ref BackOutputLabel, isTest, "0" + symbol);
+ conditionCalculator = ConditionCalculator.operation;
+ break;
+ case ConditionCalculator.firstNumber:
+ ChangeLabel(ref BackOutputLabel, isTest, MainOutputLabel.Text + symbol);
+ conditionCalculator = ConditionCalculator.operation;
+ break;
+ case ConditionCalculator.signFirstNumber:
+ ChangeLabel(ref BackOutputLabel, isTest, MainOutputLabel.Text + symbol);
+ conditionCalculator = ConditionCalculator.operation;
+ break;
+ case ConditionCalculator.operation:
+ ChangeLabel(ref BackOutputLabel, isTest, firstNumber + symbol);
+ break;
+ case ConditionCalculator.secondNumber:
+ if (symbol == '/' && AStringOfZeros(secondNumber))
+ {
+ ChangeLabel(ref MainOutputLabel, isTest, "0");
+ ChangeLabel(ref BackOutputLabel, isTest, "");
+ ChangeLabel(ref ErrorLabel, isTest, "Error");
+ firstNumber = "";
+ secondNumber = "";
+ conditionCalculator = ConditionCalculator.start;
+ }
+ else
+ {
+ var result = NumbersWithOperation(symbol, firstNumber, secondNumber).ToString();
+ ChangeLabel(ref BackOutputLabel, isTest, result.ToString() + symbol);
+ }
+ break;
+ case ConditionCalculator.signSecondNumber:
+ if (symbol == '/' && AStringOfZeros(secondNumber))
+ {
+ ChangeLabel(ref MainOutputLabel, isTest, "0");
+ ChangeLabel(ref BackOutputLabel, isTest, "");
+ ChangeLabel(ref ErrorLabel, isTest, "Error");
+ firstNumber = "";
+ secondNumber = "";
+ conditionCalculator = ConditionCalculator.start;
+ }
+ else
+ {
+ var result = NumbersWithOperation(symbol, firstNumber, secondNumber).ToString();
+ ChangeLabel(ref BackOutputLabel, isTest, result.ToString() + symbol);
+ }
+ break;
+ }
+ }
+}
\ No newline at end of file
diff --git a/CalculatorApp/CalculatorApp/Program.cs b/CalculatorApp/CalculatorApp/Program.cs
new file mode 100644
index 0000000..20460ed
--- /dev/null
+++ b/CalculatorApp/CalculatorApp/Program.cs
@@ -0,0 +1,17 @@
+namespace CalculatorApp
+{
+ internal static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ // To customize application configuration such as set high DPI settings or default font,
+ // see https://aka.ms/applicationconfiguration.
+ ApplicationConfiguration.Initialize();
+ Application.Run(new Calculator());
+ }
+ }
+}
\ No newline at end of file
diff --git a/CalculatorApp/TestsForCalculator/TestsForCalculator.cs b/CalculatorApp/TestsForCalculator/TestsForCalculator.cs
new file mode 100644
index 0000000..ba9bb52
--- /dev/null
+++ b/CalculatorApp/TestsForCalculator/TestsForCalculator.cs
@@ -0,0 +1,273 @@
+namespace TestsForCalculator;
+
+using CalculatorApp;
+using System.Reflection.Emit;
+
+public class Tests
+{
+ Functional functional;
+ ConditionCalculator conditionCalculator;
+ System.Windows.Forms.Label mainOutputLabel;
+ System.Windows.Forms.Label backOutputLabel;
+ System.Windows.Forms.Label errorLabel;
+ [SetUp]
+ public void Setup()
+ {
+ functional = new Functional();
+ conditionCalculator = ConditionCalculator.start;
+ mainOutputLabel = new System.Windows.Forms.Label();
+ backOutputLabel = new System.Windows.Forms.Label();
+ }
+
+ [Test]
+ public void CEButtonShouldWorkCorrectlyWithSecondNumber()
+ {
+ var firstNumber = "1";
+ var secondNumber = "2";
+ conditionCalculator = ConditionCalculator.secondNumber;
+ functional.CEButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true);
+ Assert.That(secondNumber, Is.EqualTo(""));
+ }
+
+ [Test]
+ public void CEButtonShouldWorkCorrectlyWithFirstNumber()
+ {
+ var firstNumber = "1";
+ var secondNumber = "2";
+ conditionCalculator = ConditionCalculator.firstNumber;
+ functional.CEButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true);
+ Assert.That(firstNumber, Is.EqualTo(""));
+ }
+
+ [Test]
+ public void SquaringButtonShouldWorkCorrectly()
+ {
+ var firstNumber = "9";
+ var secondNumber = "1";
+ conditionCalculator = ConditionCalculator.firstNumber;
+ functional.SquaringButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true);
+ Assert.That(firstNumber == "81" && conditionCalculator == ConditionCalculator.firstNumber);
+ }
+
+ [Test]
+ public void ProcentButtonShouldWorkCorrectlyWithFirstNumber()
+ {
+ var firstNumber = "9";
+ var secondNumber = "1";
+ conditionCalculator = ConditionCalculator.firstNumber;
+ functional.ProcentButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true);
+ Assert.That(firstNumber == "0" && conditionCalculator == ConditionCalculator.firstNumber);
+ }
+
+ [Test]
+ public void ProcentButtonShouldWorkCorrectlyWithSecondNumberAndDifficultProcent()
+ {
+ var firstNumber = "1000";
+ var secondNumber = "15";
+ conditionCalculator = ConditionCalculator.secondNumber;
+ functional.ProcentButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true);
+ Assert.That(secondNumber == "150" && conditionCalculator == ConditionCalculator.secondNumber);
+ }
+
+ [Test]
+ public void SignButtonShouldWorkCorrectlyWithFirstNumber()
+ {
+ var firstNumber = "100";
+ var secondNumber = "15";
+ conditionCalculator = ConditionCalculator.firstNumber;
+ functional.SignButtonClick(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true);
+ Assert.That(firstNumber == "-100" && conditionCalculator == ConditionCalculator.signFirstNumber);
+ }
+
+ [Test]
+ public void SignButtonShouldWorkCorrectlyWithSecondNumber()
+ {
+ var firstNumber = "100";
+ var secondNumber = "15";
+ conditionCalculator = ConditionCalculator.secondNumber;
+ functional.SignButtonClick(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true);
+ Assert.That(secondNumber == "-15" && conditionCalculator == ConditionCalculator.signSecondNumber);
+ }
+
+ [Test]
+ public void SignButtonShouldWorkCorrectlyThanTwicedUsed()
+ {
+ var firstNumber = "100";
+ var secondNumber = "15";
+ conditionCalculator = ConditionCalculator.firstNumber;
+ functional.SignButtonClick(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true);
+ functional.SignButtonClick(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true);
+ Assert.That(firstNumber == "100" && conditionCalculator == ConditionCalculator.signFirstNumber);
+ }
+
+ [Test]
+ public void SignButtonShouldWorkCorrectlyWithZero()
+ {
+ var firstNumber = "0";
+ var secondNumber = "15";
+ conditionCalculator = ConditionCalculator.start;
+ functional.SignButtonClick(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true);
+ Assert.That(firstNumber == "0" && conditionCalculator == ConditionCalculator.start);
+ }
+
+ [Test]
+ public void TakeRootButtonShouldWorkCorrectlyWithFirstNumber()
+ {
+ var firstNumber = "100";
+ var secondNumber = "15";
+ conditionCalculator = ConditionCalculator.firstNumber;
+ functional.TakeRootButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, ref backOutputLabel, ref errorLabel, true);
+ Assert.That(firstNumber == "10" && conditionCalculator == ConditionCalculator.firstNumber);
+ }
+
+ [Test]
+ public void TakeRootButtonShouldWorkCorrectlyWithSecondNumber()
+ {
+ var firstNumber = "100";
+ var secondNumber = "225";
+ conditionCalculator = ConditionCalculator.secondNumber;
+ functional.TakeRootButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, ref backOutputLabel, ref errorLabel, true);
+ Assert.That(secondNumber == "15" && conditionCalculator == ConditionCalculator.secondNumber);
+ }
+
+ [Test]
+ public void TakeRootButtonShouldWorkCorrectlyWithZero()
+ {
+ var firstNumber = "0";
+ var secondNumber = "5";
+ conditionCalculator = ConditionCalculator.start;
+ functional.TakeRootButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, ref backOutputLabel, ref errorLabel, true);
+ Assert.That(firstNumber == "0" && conditionCalculator == ConditionCalculator.firstNumber);
+ }
+
+ [Test]
+ public void UnitDividedByNumberButtonShouldWorkCorrectlyWithfFirstNumber()
+ {
+ var firstNumber = "10";
+ var secondNumber = "5";
+ conditionCalculator = ConditionCalculator.firstNumber;
+ functional.UnitDividedByNumberButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, ref backOutputLabel, ref errorLabel, true);
+ Assert.That(firstNumber == "0.1" && conditionCalculator == ConditionCalculator.firstNumber);
+ }
+
+ [Test]
+ public void UnitDividedByNumberButtonShouldWorkCorrectlyWithSecondNumber()
+ {
+ var firstNumber = "10";
+ var secondNumber = "5";
+ conditionCalculator = ConditionCalculator.secondNumber;
+ functional.UnitDividedByNumberButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, ref backOutputLabel, ref errorLabel, true);
+ Assert.That(secondNumber == "0.2" && conditionCalculator == ConditionCalculator.secondNumber);
+ }
+
+ [Test]
+ public void DeleteButtonShouldWorkCorrectlyWithFirstNumber()
+ {
+ var firstNumber = "10";
+ var secondNumber = "5";
+ conditionCalculator = ConditionCalculator.firstNumber;
+ functional.DeleteButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true);
+ Assert.That(firstNumber == "1" && conditionCalculator == ConditionCalculator.firstNumber);
+ }
+
+ [Test]
+ public void DeleteButtonShouldWorkCorrectlyWithDeleteAllFirstNumber()
+ {
+ var firstNumber = "1";
+ var secondNumber = "5";
+ conditionCalculator = ConditionCalculator.firstNumber;
+ functional.DeleteButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true);
+ Assert.That(firstNumber == "" && conditionCalculator == ConditionCalculator.start);
+ }
+
+ [Test]
+ public void DeleteButtonShouldWorkCorrectlyWithSecondNumber()
+ {
+ var firstNumber = "1";
+ var secondNumber = "50";
+ conditionCalculator = ConditionCalculator.secondNumber;
+ functional.DeleteButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true);
+ Assert.That(secondNumber == "5" && conditionCalculator == ConditionCalculator.secondNumber);
+ }
+
+ [Test]
+ public void DeleteButtonShouldWorkCorrectlyWithDeleteAllSecondNumber()
+ {
+ var firstNumber = "1";
+ var secondNumber = "5";
+ conditionCalculator = ConditionCalculator.secondNumber;
+ functional.DeleteButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true);
+ Assert.That(secondNumber == "" && conditionCalculator == ConditionCalculator.operation);
+ }
+
+ [Test]
+ public void AddNumberButtonShouldWorkCorrectlyWithFirstNumber()
+ {
+ var firstNumber = "1";
+ var secondNumber = "5";
+ conditionCalculator = ConditionCalculator.firstNumber;
+ functional.WorkWithNumber(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true, '2');
+ Assert.That(firstNumber == "12" && conditionCalculator == ConditionCalculator.firstNumber);
+ }
+
+ [Test]
+ public void AddNumberButtonShouldWorkCorrectlyWithSecondNumber()
+ {
+ var firstNumber = "1";
+ var secondNumber = "5";
+ conditionCalculator = ConditionCalculator.secondNumber;
+ functional.WorkWithNumber(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true, '2');
+ Assert.That(secondNumber == "52" && conditionCalculator == ConditionCalculator.secondNumber);
+ }
+
+ [Test]
+ public void EqualButtonShouldWorkCorrectly()
+ {
+ var firstNumber = "12";
+ var secondNumber = "5";
+ conditionCalculator = ConditionCalculator.secondNumber;
+ backOutputLabel.Text = "12+";
+ functional.EqualButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, ref backOutputLabel, ref errorLabel, true);
+ Assert.That(firstNumber == "17" && conditionCalculator == ConditionCalculator.operation);
+ }
+
+ [Test]
+ public void EqualButtonShouldWorkCorrectlyWithStartCondition()
+ {
+ var firstNumber = "";
+ var secondNumber = "";
+ conditionCalculator = ConditionCalculator.start;
+ functional.EqualButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, ref backOutputLabel, ref errorLabel, true);
+ Assert.That(firstNumber == "" && conditionCalculator == ConditionCalculator.start);
+ }
+
+ [Test]
+ public void ZeroShouldWorkCorrectly()
+ {
+ var firstNumber = "0";
+ var secondNumber = "5";
+ conditionCalculator = ConditionCalculator.firstNumber;
+ functional.ZeroButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true);
+ Assert.That(firstNumber == "0" && conditionCalculator == ConditionCalculator.firstNumber);
+ }
+
+ [Test]
+ public void CommaButtonShouldWorkCorrectlyWithFirstNumber()
+ {
+ var firstNumber = "0";
+ var secondNumber = "5";
+ conditionCalculator = ConditionCalculator.firstNumber;
+ functional.CommaButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true);
+ Assert.That(firstNumber == "0," && conditionCalculator == ConditionCalculator.firstNumber);
+ }
+
+ [Test]
+ public void CommaButtonShouldWorkCorrectlyWithSecondNumber()
+ {
+ var firstNumber = "0";
+ var secondNumber = "5";
+ conditionCalculator = ConditionCalculator.secondNumber;
+ functional.CommaButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref mainOutputLabel, true);
+ Assert.That(secondNumber == "5," && conditionCalculator == ConditionCalculator.secondNumber);
+ }
+}
\ No newline at end of file
diff --git a/CalculatorApp/TestsForCalculator/TestsForCalculator.csproj b/CalculatorApp/TestsForCalculator/TestsForCalculator.csproj
new file mode 100644
index 0000000..6285262
--- /dev/null
+++ b/CalculatorApp/TestsForCalculator/TestsForCalculator.csproj
@@ -0,0 +1,23 @@
+
+
+
+ net7.0-windows
+ enable
+ enable
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CalculatorApp/TestsForCalculator/Usings.cs b/CalculatorApp/TestsForCalculator/Usings.cs
new file mode 100644
index 0000000..cefced4
--- /dev/null
+++ b/CalculatorApp/TestsForCalculator/Usings.cs
@@ -0,0 +1 @@
+global using NUnit.Framework;
\ No newline at end of file