using System;
using System.Collections.Generic;
using System.Text;

namespace Gyak2
{
    internal class Aggregate
    {
        private int sum;

        public delegate void IsOddHandler(int count);

        public event IsOddHandler IsOdd;

        public int Sum {
            private get;
            set { if (value > 6000) { throw new Exception("Hiba"); } sum = value; }
        }

        private int oddcount = 0;
        public void IncludeValue(int v)
        {
            Sum += v;

            if (sum %2 == 1)
            {
                oddcount++;
                IsOdd?.Invoke(oddcount);
            }
        }
    }
}
