Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Footballer Lionella = new Footballer();

            Lionella.SalaryNotify += salary => Console.WriteLine($"Current salary: {salary}\n");
            for (int i = 0; i < 10; i++)
            {
                try
                {
                    Lionella.DopingTest();
                    Lionella.Compete();
                }
                catch (Exception details)
                {
                    Console.WriteLine(details.Message);
                }
            }
            Weightlifter Tolya = new Weightlifter();

            Tolya.MedalNotify += delegate(int bronzeMedals, int silverMedals, int goldMedals)
            {
                Console.WriteLine($"Current medals:\nGold: {goldMedals}\nSilver: {silverMedals}\nBronze: {bronzeMedals}\n");
            };
            for (int i = 0; i < 10; i++)
            {
                try
                {
                    Tolya.DopingTest();
                    Tolya.Compete();
                }
                catch (Exception details)
                {
                    Console.WriteLine(details.Message);
                }
            }
            Athlete Matvey = new Athlete();

            try
            {
                Matvey.Compete();
            }
            catch (Exception details)
            {
                Console.WriteLine(details.Message);
            }
            Matvey.Specialization = "Javelin-throwing";
            try
            {
                Matvey.Compete();
            }
            catch (Exception details)
            {
                Console.WriteLine(details.Message);
            }
            Console.ReadKey();
        }
Exemplo n.º 2
0
        public new int CompareTo(object s)
        {
            Footballer subject = s as Footballer;

            if (subject != null)
            {
                return(this.scoredGoals.CompareTo(subject.scoredGoals));
            }
            else
            {
                throw new Exception("Unable to compare these objects");
            }
        }