Beispiel #1
0
        public void Compete()
        {
            Random result = new Random();
            int    place  = result.Next(1, 16);

            Console.WriteLine($"Your team took {place} place");
            if (place == 1)
            {
                Console.WriteLine("You received a gold medal!");
                goldMedals++;
                salary += 150;
            }
            else if (place == 2)
            {
                Console.WriteLine("You received a silver medal!");
                silverMedals++;
                salary += 100;
            }
            else if (place == 3)
            {
                Console.WriteLine("You received a bronze medal!");
                bronzeMedals++;
                salary += 50;
            }
            SalaryNotify?.Invoke(salary);
            MedalNotify?.Invoke(bronzeMedals, silverMedals, goldMedals);
        }
Beispiel #2
0
        public void Compete()
        {
            if (specialization == null)
            {
                throw new Exception("You haven't set the athlet's specialization\n");
            }
            Random result   = new Random();
            double distance = 60 * result.NextDouble();
            int    place;

            if (distance > Convert.ToDouble(record))
            {
                Console.WriteLine($"Congratulations! You have set a new record: {distance} meters!");
                record = distance;
                place  = 1;
            }
            else
            {
                place = result.Next(1, 16);
            }
            Console.WriteLine($"You took {place} place");
            if (place == 1)
            {
                Console.WriteLine("You received a gold medal!");
                goldMedals++;
                salary += 150;
            }
            else if (place == 2)
            {
                Console.WriteLine("You received a silver medal!");
                silverMedals++;
                salary += 100;
            }
            else if (place == 3)
            {
                Console.WriteLine("You received a bronze medal!");
                bronzeMedals++;
                salary += 50;
            }
            SalaryNotify?.Invoke(salary);
            MedalNotify?.Invoke(bronzeMedals, silverMedals, goldMedals);
        }
        public void Compete()
        {
            Random result      = new Random();
            int    totalWeight = result.Next(60, 250);
            int    place;

            if (totalWeight > Convert.ToInt32(record))
            {
                Console.WriteLine($"Congratulations! You have set a new record: {totalWeight} kg!");
                record = totalWeight;
                place  = 1;
            }
            else
            {
                place = result.Next(1, 16);
            }
            Console.WriteLine($"You took {place} place");
            if (place == 1)
            {
                Console.WriteLine("You received a gold medal!");
                goldMedals++;
                salary += 150;
            }
            else if (place == 2)
            {
                Console.WriteLine("You received a silver medal!");
                silverMedals++;
                salary += 100;
            }
            else if (place == 3)
            {
                Console.WriteLine("You received a bronze medal!");
                bronzeMedals++;
                salary += 50;
            }
            SalaryNotify?.Invoke(salary);
            MedalNotify?.Invoke(bronzeMedals, silverMedals, goldMedals);
        }