コード例 #1
0
        public void AddEmployee(EmployeeNode employee)
        {
            if (employee == null)

            {
                throw new ArgumentNullException(

                          "Cannot insert null value!");
            }



            if (employee.hasManager)

            {
                throw new ArgumentException(

                          "The Employee already has a Manager!");
            }



            employee.hasManager = true;

            this.juniors.Add(employee);
        }
コード例 #2
0
        private long JuniorsSalarys(EmployeeNode root, string managerId)
        {
            EmployeeNode child       = root;
            bool         isRightNode = child.EmployeeId.Equals(managerId);


            if (isRightNode)
            {
                amount      = root.Salary;
                amount     += Salarys(root);
                amount     += root.juniors.Sum(t => t.Salary);
                isRightNode = false;
                return(amount);
            }
            else
            {
                foreach (var item in root.juniors)
                {
                    if (isRightNode)
                    {
                        break;
                    }
                    JuniorsSalarys(item, managerId);
                }
            }


            return(amount);
        }
コード例 #3
0
 private long Salarys(EmployeeNode root)
 {
     foreach (var item in root.juniors)
     {
         amount += item.Salary;
     }
     return(amount);
 }
コード例 #4
0
 public EmployeeHierarchy(int salary, string Id, string Manager)
 {
     boss = new EmployeeNode(salary, Id, Manager);
 }