<commit_before>﻿using System;
using Stacks;

namespace hw6_1
{
    public class Calculator
    {
        public static int Calculate(string expression)
        {
            int firstNumber = 0;
            int i = 0;
            bool isNegative = false;

            if (expression[0] == '-')
                {
                    isNegative = true;
                    ++i;
                }

            while (expression[i] >= '0' && expression[i] <= '9')
            {
                firstNumber = firstNumber * 10 + (int)expression[i] - 48;
                ++i;
                if (i == expression.Length)
                {
                    if (isNegative)
                    {
                        firstNumber = 0 - firstNumber;
                    }
                    return firstNumber;
                }
            }

            if (isNegative)
            {
                firstNumber = 0 - firstNumber;
            }

            int OperationPlace = i;
            ++i;
            int secondNumber = 0;

            while (i < expression.Length)
            {
                secondNumber = secondNumber * 10 + (int)expression[i] - 48;
                ++i;
            }

            var calc = new StackCalculator(new Stack());
            calc.Push(firstNumber);
            calc.Push(secondNumber);
            switch (expression[OperationPlace])
            {
                case '/':
                    calc.Divide();
                    break;
                case '*': 
                    calc.Multiply();
                    break;
                case '+':
                    calc.Add();
                    break;
                case '-':
                    calc.Subtract();
                    break;
            }
            return calc.Result();
        }
    }
}
<commit_msg>fixed<commit_after>﻿using System;
using Stacks;

namespace hw6_1
{
    public class Calculator
    {
        public static int Calculate(string expression)
        {
            int firstNumber = 0;
            int i = 0;
            bool isNegative = false;

            if (expression[0] == '-')
            {
                isNegative = true;
                ++i;
            }

            while (expression[i] >= '0' && expression[i] <= '9')
            {
                firstNumber = firstNumber * 10 + (int)expression[i] - 48;
                ++i;
                if (i == expression.Length)
                {
                    if (isNegative)
                    {
                        firstNumber = 0 - firstNumber;
                    }
                    return firstNumber;
                }
            }

            if (isNegative)
            {
                firstNumber = 0 - firstNumber;
            }

            int operationPlace = i;
            ++i;
            int secondNumber = 0;

            while (i < expression.Length)
            {
                secondNumber = secondNumber * 10 + (int)expression[i] - 48;
                ++i;
            }

            var calc = new StackCalculator(new Stack());
            calc.Push(firstNumber);
            calc.Push(secondNumber);
            switch (expression[operationPlace])
            {
                case '/':
                    calc.Divide();
                    break;
                case '*': 
                    calc.Multiply();
                    break;
                case '+':
                    calc.Add();
                    break;
                case '-':
                    calc.Subtract();
                    break;
            }
            return calc.Result();
        }
    }
}

{'fraction_non_alphanumeric': 0.09552733296521258, 'fraction_numerical': 0.009939260077305357, 'mean_word_length': 0.8124062031015508, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7454589', 'n_tokens_mistral': 931, 'n_tokens_neox': 810, 'n_words': 186}