Beispiel #1
0
 public bool Equals(Ministry org) // аргумент типа Ministry
 {
     if (org == null)
     {
         return(false);
     }
     return(org.depCount == this.depCount && org.infoBoss == this.infoBoss && org.mSalary == this.mSalary && org.persCount == this.persCount);
 }
Beispiel #2
0
        public Registry()
        {
            Organization unic   = new University("Нормальный, приходит вовремя", 3, 100, 1300, 20000);
            Organization plant  = new Plant("Отличный, ценит работников", 5, 70, 1000, 10000);
            Organization minist = new Ministry("Неприемлемый, грабит", 10, 450, 1100, 200000);

            ObjArray = new Organization[] { unic, plant, minist };

            //printInfo(unic);
            //printInfo(plant);
            //printInfo(minist);
        }
Beispiel #3
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            Ministry org = obj as Ministry; // возвращает null если объект нельзя привести к типу Ministry

            if (org as Organization == null)
            {
                return(false);
            }

            return(org.depCount == this.depCount && org.infoBoss == this.infoBoss && org.mSalary == this.mSalary && org.persCount == this.persCount && org.ministryCosts == this.ministryCosts);
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            Registry regist = new Registry();

            // Console.WriteLine(regist);
            Registry regist1 = regist.DeepCopy();

            Console.WriteLine(regist1);// ToString
            Organization unic  = new Ministry("Нормальный, приходит вовремя", 3, 100, 1300, 20000);
            Organization unic1 = new Ministry("Нормальный, приходит вовремя", 3, 100, 1300, 20000);

            if (unic.Equals(unic1))
            {
                Console.WriteLine("Equals");
            }
            else
            {
                Console.WriteLine(" Not Equals");
            }

            Console.WriteLine("\n" + unic.GetHashCode() + " " + unic1.GetHashCode());

            int a = 4;
            int b = 2;
            int c = 2; // int c =0;

            try
            {
                if (c == 0)
                {
                    throw new DivideByZero();
                }
                a = b / c;
            }
            catch (DivideByZero e)
            {
                Console.WriteLine(e.Message);
            }


            Console.ReadLine();
        }
Beispiel #5
0
        public Ministry DeepCopy()
        {
            Ministry obj = new Ministry(this.infoBoss, this.depCount, this.persCount, this.mSalary, this.ministryCosts);

            return(obj);
        }