Exemple #1
0
 public void PrintAllByPosition(string position)
 {
     _output.Print($"There are all employees with position {position}:");
     foreach (var employee in _root.GetAllWithPosition(position))
     {
         _output.Print(employee.ToString());
     }
 }
        public virtual List <EmployeeComponent> GetAllWithPosition(string position, List <EmployeeComponent> employees = null)
        {
            if (employees == null)
            {
                employees = new List <EmployeeComponent>();
            }
            if (Position == position)
            {
                employees.Add(this);
            }
            IEnumerator iterator = CreateIterator();
            bool        hasNext  = iterator.MoveNext();

            while (hasNext)
            {
                EmployeeComponent employee = (EmployeeComponent)iterator.Current;
                employees = employee.GetAllWithPosition(position, employees);
                hasNext   = iterator.MoveNext();
            }

            return(employees);
        }