Добавьте файлы проекта.
This commit is contained in:
parent
0396adddb6
commit
dcfd7c6e70
21 changed files with 1928 additions and 0 deletions
23
Services/InputService.cs
Normal file
23
Services/InputService.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
namespace calculator.Services
|
||||
{
|
||||
internal class InputService : IInputService
|
||||
{
|
||||
public string TryInput(string input)
|
||||
{
|
||||
//если есть знак "бесконечность" - не даёт писать цифры после него
|
||||
if (input.Contains('∞'))
|
||||
{
|
||||
input = input[..^1];
|
||||
}
|
||||
|
||||
//ситуация: слева ноль, а после него НЕ запятая, тогда ноль можно удалить
|
||||
if (input[0] == '0' && (input.IndexOf(".", StringComparison.Ordinal) != 1))
|
||||
{
|
||||
input = input.Remove(0, 1);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue