Ejemplo n.º 1
0
 public Participant(string firstName, string lastName, int age, AcademyRole role)
 {
     FirstName = firstName;
     LastName  = lastName;
     Age       = age;
     Role      = role;
 }
Ejemplo n.º 2
0
 public static void FindParticipantByRole(Participant[] participants, AcademyRole role)
 {
     Console.ForegroundColor = ConsoleColor.Red;
     foreach (var participant in participants)
     {
         if (participant.Role == role)
         {
             participant.PrintFullName();
         }
     }
 }
Ejemplo n.º 3
0
 // wrapper class for the FindParticipantByRole method
 public static void FindParticipantByRole(AcademyRole role, Participant[] participants)
 {
     foreach (var participant in participants)
     {
         Console.BackgroundColor = ConsoleColor.DarkBlue;
         if (participant.Role == role)
         {
             participant.PrintParticipant();
         }
         Console.BackgroundColor = ConsoleColor.Black;
     }
 }
        // if all members are static, that class becomes static
        // does not instantiate with new

        // A C# static class is a class that can't be instantiated.
        // A static class can contain static members only.
        // You can‘t create an object for the static class.
        // We do not use the NEW keyword.
        public static void FindParticipantByRole(AcademyRole role, Participant[] participants)
        {
            foreach (Participant item in participants)
            {
                Console.BackgroundColor = ConsoleColor.DarkBlue;
                if (item.Role == role)
                {
                    item.PrintInfo();
                }
                Console.BackgroundColor = ConsoleColor.Black;
            }
        }
Ejemplo n.º 5
0
        public static void FindParticipantByRole(List <Participant> participants, AcademyRole role)
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("----------------------------");
            Console.WriteLine($"{role}:");
            Console.WriteLine("----------------------------");

            foreach (var participant in participants)
            {
                if (participant.Role == role)
                {
                    participant.PrintFullName();
                }
            }

            Console.ResetColor();
        }