This repository has been archived on 2024-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
NG_2023_Stanislav_Mykhailenko/Lesson_6/Task_1/Program.cs

36 lines
811 B
C#
Raw Normal View History

/*
* Lesson 6 Task 1: calculator using delegates, events and lambdas
* Author: Stanislav Mykhailenko
* License: Unlicense
*/
2023-04-12 14:51:12 +00:00
using Lesson6.Classes;
namespace Lesson6
{
class Program
{
static void Main(string[] args)
{
Calculator calc = new Calculator();
// subscribe to the event
calc.CalculationPerformed += result => Console.WriteLine($"Result: {result}");
while (true)
{
Console.Write("Enter expression (e.g. 2 + 2) or exit: ");
string? expression = Console.ReadLine();
if (expression == null)
continue;
if (expression == "exit")
break;
calc.Calculate(expression);
}
}
}
}