Добавлены Операции и Константы. Изменено оформление формы, так как были отключены кнопки:

- Градусы;
- Радианы;
- Грады;
- Память ((MC, MR, MS, M-, M+);
- dms;
- F-E.
This commit is contained in:
Мария 2024-04-14 23:59:47 +03:00
parent a9be1638c3
commit a906568f42
8 changed files with 117 additions and 95 deletions

View file

@ -23,9 +23,7 @@ public static class CalculatorExtensions
case Operation.Square: case Operation.Square:
case Operation.Log: case Operation.Log:
case Operation.Ln: case Operation.Ln:
case Operation.Exp:
case Operation.Inv: case Operation.Inv:
case Operation.Pi:
case Operation.OneDiv: case Operation.OneDiv:
case Operation.Mod: case Operation.Mod:
case Operation.Neg: case Operation.Neg:

View file

@ -18,7 +18,6 @@ public enum Operation
Ln, Ln,
Exp, Exp,
Inv, Inv,
Pi,
OneDiv, OneDiv,
Mod, Mod,
Neg, Neg,
@ -30,5 +29,14 @@ public enum Operation
Tanh, Tanh,
Tan, Tan,
OpenBracket, OpenBracket,
CloseBracket CloseBracket,
Int,
Dms,
FE,
PowX
}
public enum Constants
{
Pi,
Exp
} }

View file

@ -2,6 +2,7 @@
using calculator.Model; using calculator.Model;
using calculator.Services; using calculator.Services;
using calculator.View; using calculator.View;
using System.Runtime.InteropServices;
namespace calculator.Controller; namespace calculator.Controller;
@ -25,19 +26,24 @@ public class CaculatorController
_view.ClearPressed += OnClearPressed; _view.ClearPressed += OnClearPressed;
_view.CalculatePressed += OnCalculatePressed; _view.CalculatePressed += OnCalculatePressed;
_view.SingleOperatorPressed += OnSingleOperationPressed; _view.SingleOperatorPressed += OnSingleOperationPressed;
_view.Constants += OnConstantsPressed;
OnClearPressed(true); OnClearPressed(true);
} }
private void OnSingleOperationPressed(Operation operation) private void OnSingleOperationPressed(Operation operation)
{ {
if (_data.Values.Count == 0)
return;
if (double.TryParse(_data.Input, out var value) == false) if (double.TryParse(_data.Input, out var value) == false)
return; {
if (_data.Values.Count > 0)
{
value = _data.Values.Pop()!.Value;
}
else { return; }
}
_data.Values.Push(_caculator.Calculate(operation, value)); _data.Values.Push(_caculator.Calculate(operation, value));
UpdateView(_data.Values.Peek()!.Value); UpdateView(_data.Values.Peek()!.Value);
_data.Input = null;
} }
private void OnClearPressed(bool full) private void OnClearPressed(bool full)
@ -160,4 +166,26 @@ public class CaculatorController
{ {
_view.UpdateView(input); _view.UpdateView(input);
} }
private void OnConstantsPressed(Constants constants)
{
if (_data.Operations.Count == 0 && _data.Input == null)
{
Clear(full: true);
} }
double output = 0;
switch (constants)
{
case Constants.Pi:
output = Math.PI;
break;
case Constants.Exp:
output = Math.E;
break;
}
_data.Input = output.ToString("0.#####");
UpdateView(output);
}
}

66
Form1.Designer.cs generated
View file

@ -29,7 +29,7 @@
private void InitializeComponent() private void InitializeComponent()
{ {
panel1 = new Panel(); panel1 = new Panel();
button49 = new Button(); PowX = new Button();
Log_button = new Button(); Log_button = new Button();
Mod_button = new Button(); Mod_button = new Button();
Exp_button = new Button(); Exp_button = new Button();
@ -97,7 +97,7 @@
// panel1 // panel1
// //
panel1.BackColor = Color.MediumSlateBlue; panel1.BackColor = Color.MediumSlateBlue;
panel1.Controls.Add(button49); panel1.Controls.Add(PowX);
panel1.Controls.Add(Log_button); panel1.Controls.Add(Log_button);
panel1.Controls.Add(Mod_button); panel1.Controls.Add(Mod_button);
panel1.Controls.Add(Exp_button); panel1.Controls.Add(Exp_button);
@ -157,16 +157,17 @@
panel1.Size = new Size(573, 338); panel1.Size = new Size(573, 338);
panel1.TabIndex = 0; panel1.TabIndex = 0;
// //
// button49 // PowX
// //
button49.FlatStyle = FlatStyle.Flat; PowX.FlatStyle = FlatStyle.Flat;
button49.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point); PowX.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
button49.Location = new Point(232, 296); PowX.Location = new Point(232, 296);
button49.Name = "button49"; PowX.Name = "PowX";
button49.Size = new Size(51, 37); PowX.Size = new Size(51, 37);
button49.TabIndex = 55; PowX.TabIndex = 55;
button49.Text = "10ᵜ"; PowX.Text = "10ᵜ";
button49.UseVisualStyleBackColor = true; PowX.UseVisualStyleBackColor = true;
PowX.Click += OnPowXButtonClick;
// //
// Log_button // Log_button
// //
@ -206,8 +207,11 @@
// //
// button53 // button53
// //
button53.Cursor = Cursors.No;
button53.Enabled = false;
button53.FlatStyle = FlatStyle.Flat; button53.FlatStyle = FlatStyle.Flat;
button53.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point); button53.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
button53.ForeColor = Color.Tomato;
button53.Location = new Point(4, 296); button53.Location = new Point(4, 296);
button53.Name = "button53"; button53.Name = "button53";
button53.Size = new Size(51, 37); button53.Size = new Size(51, 37);
@ -325,8 +329,12 @@
// //
// dms_button // dms_button
// //
dms_button.BackgroundImageLayout = ImageLayout.None;
dms_button.Cursor = Cursors.No;
dms_button.Enabled = false;
dms_button.FlatStyle = FlatStyle.Flat; dms_button.FlatStyle = FlatStyle.Flat;
dms_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point); dms_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
dms_button.ForeColor = Color.Tomato;
dms_button.Location = new Point(4, 210); dms_button.Location = new Point(4, 210);
dms_button.Name = "dms_button"; dms_button.Name = "dms_button";
dms_button.Size = new Size(51, 37); dms_button.Size = new Size(51, 37);
@ -392,6 +400,7 @@
Int_button.TabIndex = 36; Int_button.TabIndex = 36;
Int_button.Text = "Int"; Int_button.Text = "Int";
Int_button.UseVisualStyleBackColor = true; Int_button.UseVisualStyleBackColor = true;
Int_button.Click += OnIntButtonClick;
// //
// button23 // button23
// //
@ -731,8 +740,11 @@
// //
// button5 // button5
// //
button5.Cursor = Cursors.No;
button5.Enabled = false;
button5.FlatStyle = FlatStyle.Flat; button5.FlatStyle = FlatStyle.Flat;
button5.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point); button5.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
button5.ForeColor = Color.Tomato;
button5.Location = new Point(517, 81); button5.Location = new Point(517, 81);
button5.Name = "button5"; button5.Name = "button5";
button5.Size = new Size(51, 37); button5.Size = new Size(51, 37);
@ -742,8 +754,11 @@
// //
// button4 // button4
// //
button4.Cursor = Cursors.No;
button4.Enabled = false;
button4.FlatStyle = FlatStyle.Flat; button4.FlatStyle = FlatStyle.Flat;
button4.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point); button4.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
button4.ForeColor = Color.Tomato;
button4.Location = new Point(460, 81); button4.Location = new Point(460, 81);
button4.Name = "button4"; button4.Name = "button4";
button4.Size = new Size(51, 37); button4.Size = new Size(51, 37);
@ -753,8 +768,11 @@
// //
// button3 // button3
// //
button3.Cursor = Cursors.No;
button3.Enabled = false;
button3.FlatStyle = FlatStyle.Flat; button3.FlatStyle = FlatStyle.Flat;
button3.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point); button3.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
button3.ForeColor = Color.Tomato;
button3.Location = new Point(403, 81); button3.Location = new Point(403, 81);
button3.Name = "button3"; button3.Name = "button3";
button3.Size = new Size(51, 37); button3.Size = new Size(51, 37);
@ -764,8 +782,11 @@
// //
// button2 // button2
// //
button2.Cursor = Cursors.No;
button2.Enabled = false;
button2.FlatStyle = FlatStyle.Flat; button2.FlatStyle = FlatStyle.Flat;
button2.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point); button2.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
button2.ForeColor = Color.Tomato;
button2.Location = new Point(346, 81); button2.Location = new Point(346, 81);
button2.Name = "button2"; button2.Name = "button2";
button2.Size = new Size(51, 37); button2.Size = new Size(51, 37);
@ -775,8 +796,11 @@
// //
// button1 // button1
// //
button1.Cursor = Cursors.No;
button1.Enabled = false;
button1.FlatStyle = FlatStyle.Flat; button1.FlatStyle = FlatStyle.Flat;
button1.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point); button1.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
button1.ForeColor = Color.Tomato;
button1.Location = new Point(289, 81); button1.Location = new Point(289, 81);
button1.Name = "button1"; button1.Name = "button1";
button1.Size = new Size(51, 37); button1.Size = new Size(51, 37);
@ -798,8 +822,11 @@
// radioButton3 // radioButton3
// //
radioButton3.AutoSize = true; radioButton3.AutoSize = true;
radioButton3.BackgroundImageLayout = ImageLayout.None;
radioButton3.Cursor = Cursors.No;
radioButton3.Enabled = false;
radioButton3.Font = new Font("Microsoft Sans Serif", 11.25F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point); radioButton3.Font = new Font("Microsoft Sans Serif", 11.25F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point);
radioButton3.ForeColor = Color.FromArgb(255, 192, 255); radioButton3.ForeColor = Color.Tomato;
radioButton3.Location = new Point(197, 13); radioButton3.Location = new Point(197, 13);
radioButton3.Name = "radioButton3"; radioButton3.Name = "radioButton3";
radioButton3.Size = new Size(76, 22); radioButton3.Size = new Size(76, 22);
@ -811,8 +838,11 @@
// radioButton2 // radioButton2
// //
radioButton2.AutoSize = true; radioButton2.AutoSize = true;
radioButton2.BackgroundImageLayout = ImageLayout.None;
radioButton2.Cursor = Cursors.No;
radioButton2.Enabled = false;
radioButton2.Font = new Font("Microsoft Sans Serif", 11.25F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point); radioButton2.Font = new Font("Microsoft Sans Serif", 11.25F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point);
radioButton2.ForeColor = Color.FromArgb(255, 192, 255); radioButton2.ForeColor = Color.Tomato;
radioButton2.Location = new Point(98, 13); radioButton2.Location = new Point(98, 13);
radioButton2.Name = "radioButton2"; radioButton2.Name = "radioButton2";
radioButton2.Size = new Size(95, 22); radioButton2.Size = new Size(95, 22);
@ -824,8 +854,11 @@
// radioButton1 // radioButton1
// //
radioButton1.AutoSize = true; radioButton1.AutoSize = true;
radioButton1.BackgroundImageLayout = ImageLayout.None;
radioButton1.Cursor = Cursors.No;
radioButton1.Enabled = false;
radioButton1.Font = new Font("Microsoft Sans Serif", 11.25F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point); radioButton1.Font = new Font("Microsoft Sans Serif", 11.25F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point);
radioButton1.ForeColor = Color.FromArgb(255, 192, 255); radioButton1.ForeColor = Color.Tomato;
radioButton1.Location = new Point(6, 13); radioButton1.Location = new Point(6, 13);
radioButton1.Name = "radioButton1"; radioButton1.Name = "radioButton1";
radioButton1.Size = new Size(93, 22); radioButton1.Size = new Size(93, 22);
@ -850,6 +883,7 @@
// linkLabel1 // linkLabel1
// //
linkLabel1.AutoSize = true; linkLabel1.AutoSize = true;
linkLabel1.Enabled = false;
linkLabel1.LinkColor = Color.FromArgb(255, 192, 255); linkLabel1.LinkColor = Color.FromArgb(255, 192, 255);
linkLabel1.Location = new Point(16, 6); linkLabel1.Location = new Point(16, 6);
linkLabel1.Name = "linkLabel1"; linkLabel1.Name = "linkLabel1";
@ -861,6 +895,7 @@
// linkLabel2 // linkLabel2
// //
linkLabel2.AutoSize = true; linkLabel2.AutoSize = true;
linkLabel2.Enabled = false;
linkLabel2.LinkColor = Color.FromArgb(255, 192, 255); linkLabel2.LinkColor = Color.FromArgb(255, 192, 255);
linkLabel2.Location = new Point(49, 6); linkLabel2.Location = new Point(49, 6);
linkLabel2.Name = "linkLabel2"; linkLabel2.Name = "linkLabel2";
@ -872,6 +907,7 @@
// linkLabel3 // linkLabel3
// //
linkLabel3.AutoSize = true; linkLabel3.AutoSize = true;
linkLabel3.Enabled = false;
linkLabel3.LinkColor = Color.FromArgb(255, 192, 255); linkLabel3.LinkColor = Color.FromArgb(255, 192, 255);
linkLabel3.Location = new Point(102, 6); linkLabel3.Location = new Point(102, 6);
linkLabel3.Name = "linkLabel3"; linkLabel3.Name = "linkLabel3";
@ -916,7 +952,7 @@
private LinkLabel linkLabel1; private LinkLabel linkLabel1;
private LinkLabel linkLabel2; private LinkLabel linkLabel2;
private LinkLabel linkLabel3; private LinkLabel linkLabel3;
private Button button49; private Button PowX;
private Button Log_button; private Button Log_button;
private Button Mod_button; private Button Mod_button;
private Button Exp_button; private Button Exp_button;

View file

@ -15,6 +15,7 @@ namespace calculator
public event Action<Operation>? SingleOperatorPressed; public event Action<Operation>? SingleOperatorPressed;
public event Action<bool>? ClearPressed; public event Action<bool>? ClearPressed;
public event Action? CalculatePressed; public event Action? CalculatePressed;
public event Action<Constants>? Constants;
public void UpdateView(string input) public void UpdateView(string input)
{ {
@ -83,7 +84,7 @@ namespace calculator
private void OnDotButtonClick(object sender, EventArgs e) private void OnDotButtonClick(object sender, EventArgs e)
{ {
OperandPressed?.Invoke('.'); OperandPressed?.Invoke(',');
} }
private void OnNegativeButtonClick(object sender, EventArgs e) private void OnNegativeButtonClick(object sender, EventArgs e)
@ -198,7 +199,7 @@ namespace calculator
private void OnLogButtonClick(object sender, EventArgs e) private void OnLogButtonClick(object sender, EventArgs e)
{ {
SingleOperatorPressed?.Invoke(Operation.Log); OperatorPressed?.Invoke(Operation.Log);
} }
private void OnInvButtonClick(object sender, EventArgs e) private void OnInvButtonClick(object sender, EventArgs e)
@ -213,12 +214,12 @@ namespace calculator
private void OnExpButtonClick(object sender, EventArgs e) private void OnExpButtonClick(object sender, EventArgs e)
{ {
SingleOperatorPressed?.Invoke(Operation.Exp); Constants?.Invoke(Common.Constants.Exp);
} }
private void OnPiButtonClick(object sender, EventArgs e) private void OnPiButtonClick(object sender, EventArgs e)
{ {
SingleOperatorPressed?.Invoke(Operation.Pi); Constants?.Invoke(Common.Constants.Pi);
} }
private void OnOpenBracketButtonClick(object? sender, EventArgs e) private void OnOpenBracketButtonClick(object? sender, EventArgs e)
@ -230,5 +231,15 @@ namespace calculator
{ {
OperatorPressed?.Invoke(Operation.CloseBracket); OperatorPressed?.Invoke(Operation.CloseBracket);
} }
private void OnIntButtonClick(object sender, EventArgs e)
{
SingleOperatorPressed?.Invoke(Operation.Int);
}
private void OnPowXButtonClick(object sender, EventArgs e)
{
SingleOperatorPressed?.Invoke(Operation.PowX);
}
} }
} }

View file

@ -120,78 +120,18 @@
<metadata name="panel1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="panel1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="button49.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="PowX.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button50.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button51.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button52.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="button53.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="button53.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="button44.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button45.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button46.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button47.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button48.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button39.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button40.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button41.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button42.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button43.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button34.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button35.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button36.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button37.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button38.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button23.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="button23.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="button30.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="button30.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="button31.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button32.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button33.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="button33.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>

View file

@ -31,6 +31,8 @@ namespace calculator.Services
return Math.Pow(a, b); return Math.Pow(a, b);
case Operation.Mod: case Operation.Mod:
return a % b; return a % b;
case Operation.Log:
return Math.Log(a, b);
default: default:
throw new ArgumentException($"Invalid operator: {token}"); throw new ArgumentException($"Invalid operator: {token}");
} }
@ -75,16 +77,14 @@ namespace calculator.Services
return Math.Pow(a, 3); return Math.Pow(a, 3);
case Operation.CubeRoot: case Operation.CubeRoot:
return Math.Pow(a, 1 / 3); return Math.Pow(a, 1 / 3);
case Operation.Log:
return Math.Log10(a);
case Operation.Ln: case Operation.Ln:
return Math.Log(a); return Math.Log(a);
case Operation.Exp:
return Math.Exp(a);
case Operation.Inv: case Operation.Inv:
return 1 / a; return 1 / a;
case Operation.Pi: case Operation.Int:
return Math.PI; return Math.Round(a);
case Operation.PowX:
return Math.Pow(10, a);
default: default:
throw new ArgumentException($"Invalid operator: {token}"); throw new ArgumentException($"Invalid operator: {token}");
} }

View file

@ -9,5 +9,6 @@ public interface ICaculatorView
public event Action<bool> ClearPressed; public event Action<bool> ClearPressed;
public event Action CalculatePressed; public event Action CalculatePressed;
public event Action<Operation> SingleOperatorPressed; public event Action<Operation> SingleOperatorPressed;
public event Action<Constants> Constants;
public void UpdateView(string input); public void UpdateView(string input);
} }