Exemplo n.º 1
0
        public override bool Equals(object obj)
        {
            if (!base.Equals(obj))
            {
                return(false);
            }
            CookedFood rhs = (CookedFood)obj;

            return(this._cookingMethod == rhs._cookingMethod);
        }
        public static void Run()
        {
            Food       apple        = new Food("apple", FoodGroup.Fruit);
            CookedFood stewedApple  = new CookedFood("stewed", "apple", FoodGroup.Fruit);
            CookedFood bakedApple   = new CookedFood("baked", "apple", FoodGroup.Fruit);
            CookedFood stewedApple2 = new CookedFood("stewed", "apple", FoodGroup.Fruit);
            Food       apple2       = new Food("apple", FoodGroup.Fruit);

            ////will work if == operator in base class: return x._name == y._name && x._group == y._group; //WROOOONGGG!!!!!!
            //if (bakedApple == stewedApple)
            //{
            //    System.Console.WriteLine("CHECK OP: bakedApple == stewedApple");
            //}
            //else
            //{
            //    System.Console.WriteLine("CHECK OP: bakedApple != stewedApple");
            //}

            DisplayWhetherEqual(apple, stewedApple); //if (obj.GetType() != this.GetType())
            DisplayWhetherEqual(stewedApple, bakedApple);
            DisplayWhetherEqual(stewedApple, stewedApple2);
            DisplayWhetherEqual(apple, apple2);
            DisplayWhetherEqual(apple, apple);
        }