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

namespace EventSample
{
    public class Employee
    {

        private string id="";
        private string name="";
        private int salary;

        //public event System.EventHandler<EventSample.SalaryErrEventArgs> SalaryErr;
        public event SalaryErrHandler SalaryErr;

        public Employee(string id, string name):this(id,name,20000)
        {
           
        }

        public Employee(string id, string name, int salary) {
            this.id = id;
            Name = name;
            Salary = salary;
        }


        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                if (value != null) {
                    name = value;
                }
            }
        }

        public int Salary
        {
            get
            {
                return salary;
            }
            set
            {
                if ((value >= 20000) && (value <= 100000))
                {
                    salary = value;
                }
                else
                {
                    SalaryErrEventArgs e = new SalaryErrEventArgs(id);
                    OnSalaryErr(e);
                }

            }
        }

        public override string ToString()
        {
            return "Employee ID = " + id + ", Name = " + name;
        }

       protected virtual void OnSalaryErr(SalaryErrEventArgs args)
        {
            SalaryErr(this, args);
        }
    }
}
