Пример #1
0
        public Int32 CompareTo(Player player)
        {
            Actress b      = (Actress)player;
            int     result = b.Weight - this.Weight;

            return(result);
        }
Пример #2
0
        // it3:调用演员的CompareTo方法进行条件比较,返回选择的演员


        static void Main(string[] args)
        {
            // 先设置一个预选名单,圈定几个预选名额

            Actor actorA = new Actor("李*峰", 180);

            Actor actorB = new Actor("王*蓝", 165);

            Actress actressA = new Actress("徐*珊", 110);

            Actress actressB = new Actress("杨*琳", 90);


            // 最终从预选名单中选择一名男主角和一名女主角

            Console.WriteLine("选择{0}作为电影的男主角", WhoIsBetter(actorA, actorB).Name);

            Console.WriteLine("选择{0}作为电影的女主角", WhoIsBetter(actressA, actressB).Name);
        }