using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;

namespace Gyak1
{
    internal class TemperatureMonitor
    {
        [XmlAttribute("Temp")]
        private double currentTemperature;

        public delegate void FeverEventHandler();

        public event FeverEventHandler FeverDetected;

        public double CurrentTemperature {
            set {
                if (value < -10 || value > 60) {
                    throw new Exception("Baj van");
                }
                currentTemperature = value;
            }
            get {
                return currentTemperature;
            }
        }

        public void Increase(double p) {
            double oldTemp = CurrentTemperature;
            CurrentTemperature += p;
            double newTemp = CurrentTemperature;

            if(oldTemp < 37 && newTemp >= 37)
            {
                FeverDetected?.Invoke(this, EventArgs.Empty);
            }
        }

        public TemperatureMonitor(double initialTemperature)
        {
            CurrentTemperature = initialTemperature;

        }


    }
}
