예제 #1
0
        static void Main(string[] args)
        {
            tiger tiger1 = new tiger(10, "boy", "yellow", 1000);
            tiger tiger2 = new tiger(9, "girl", "black", 900);
            cat   cat1   = new cat(5, "boy", "white", 100);
            cat   cat2   = new cat(3, "girl", "yellow", 80);

            Console.WriteLine(tiger1);
            Console.WriteLine(cat1);
            Console.WriteLine(tiger1.Equals(cat1));
            Console.WriteLine(tiger2.Equals(tiger1));
        }
예제 #2
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            tiger cat = null;

            if (cat.GetType().Equals(obj.GetType()))
            {
                return(true);
            }
            cat ti = obj as cat;

            return(this.color.Equals(ti.color) && this.weight.Equals(ti.weight));
        }