public override bool Equals(object obj)
        {
            //if (ReferenceEquals(obj, this))
            //  return true;
            if (!base.Equals(obj))
            {
                return(false);
            }
            CookedFood rhs = (CookedFood)obj;

            return(this._cookingMethod == rhs._cookingMethod);
        }
        static void Main(string[] args)
        {
            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);

            DisplayWhetherEqual(apple, stewedApple);
            DisplayWhetherEqual(stewedApple, bakedApple);
            DisplayWhetherEqual(stewedApple, stewedApple2);
            DisplayWhetherEqual(apple, apple2);
            DisplayWhetherEqual(apple, apple);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Food apple1 = new Food("Apple", FoodGroup.Fruit);
            Food apple2 = new Food("Apple", FoodGroup.Fruit);

            CookedFood stewedApple = new CookedFood("Apple", FoodGroup.Fruit, "Stewed");
            CookedFood bakedApple  = new CookedFood("Apple", FoodGroup.Fruit, "Baked");


            DisplayWhetherEqual(apple1, bakedApple);
            DisplayWhetherEqual(apple1, stewedApple);
            DisplayWhetherEqual(bakedApple, stewedApple);

            DisplayWhetherEqual(apple1, apple2);
        }