コード例 #1
0
        public void CreatePosition(PositionNode parent,
                                   Position positionToCreate,
                                   string parentPositionName)
        {
            PositionNode newNode = new PositionNode();

            newNode.Position = positionToCreate;
            if (Root == null)
            {
                Root = newNode;
                return;
            }
            if (parent == null)
            {
                return;
            }
            if (parent.Position.Name == parentPositionName)
            {
                if (parent.left == null)
                {
                    parent.left = newNode;
                    return;
                }
                parent.right = newNode;
                return;
            }
            CreatePosition(parent.left, positionToCreate, parentPositionName);
            CreatePosition(parent.right, positionToCreate, parentPositionName);
        }
コード例 #2
0
 public double TotalTaxes(PositionNode from)
 {
     if (from == null)
     {
         return(0);
     }
     return((from.Position.Salary * from.Position.tax) + TotalTaxes(from.Left) + TotalTaxes(from.Right));
 }
コード例 #3
0
 public float AddSalaries(PositionNode from)
 {
     if (from == null)
     {
         return(0);
     }
     return(from.Position.Salary + AddSalaries(from.left) + AddSalaries(from.right));
 }
コード例 #4
0
 public float addSalaries(PositionNode from)
 {
     if (from == null)
     {
         return(0);
     }
     return(from.Position.Salary + addSalaries(from.Left) + addSalaries(from.Right));
 }
コード例 #5
0
 //Add salary tax (percentaje 0%-30%), each position has a different tax percentaje, Point 4
 public float taxSalary(PositionNode from)
 {
     if (from == null)
     {
         return(0);
     }
     return((from.Position.Salary * Convert.ToSingle(from.Position.Tax)) + taxSalary(from.Left) + taxSalary(from.Right));
 }
コード例 #6
0
 //Sum of the number of people that the tree has
 public float amountPersonal(PositionNode from)
 {
     if (from == null)
     {
         return(0);
     }
     return(1 + amountPersonal(from.Left) + amountPersonal(from.Right));
 }
コード例 #7
0
 public float AddTax(PositionNode from)
 {
     if (from == null)
     {
         return(0);
     }
     return((from.Position.Salary * from.Position.Tax / 100) + AddTax(from.Left) + AddTax(from.Right));
 }
コード例 #8
0
        public float SumSalaries(PositionNode node)
        {
            if (node == null)
            {
                return(0);
            }

            return(node.Position.Salary + SumSalaries(node.Left) + SumSalaries(node.Right));
        }
コード例 #9
0
        public float SumTax(PositionNode node)
        {
            if (node == null)
            {
                return(0);
            }

            return(node.Position.TaxValue + SumTax(node.Left) + SumTax(node.Right));
        }
コード例 #10
0
        public float Addsalaries2(PositionNode from)
        {
            if (from == null)
            {
                return(0);
            }

            return(from.Position.Salary + Addsalaries2(from.Left));
        }
コード例 #11
0
        public float Addpromedios(PositionNode from)
        {
            if (from == null)
            {
                return(0);
            }

            return(from.Position.total + Addpromedios(from.Left) + Addpromedios(from.Right));
        }
コード例 #12
0
        public float CalcNnodo(PositionNode from)
        {
            if (from == null)
            {
                return(0);
            }

            return(from.Position.NNodo + CalcNnodo(from.Left) + CalcNnodo(from.Right));
        }
コード例 #13
0
 public void PrintTree(PositionNode from)
 {
     if (from == null)
     {
         return;
     }
     Console.WriteLine($"{from.Position.Name} : {from.Position.Salary}");
     PrintTree(from.left);
     PrintTree(from.right);
 }
コード例 #14
0
        public int Node(PositionNode nodo)
        {
            if (nodo != null)
            {
                Node(nodo.Left); Node(nodo.Right);

                CountNodo++;
            }
            return(CountNodo);
        }
コード例 #15
0
        //2,2

        public float CountEmployees(PositionNode from)
        {
            if (from == null)
            {
                return(count);
            }
            count++;
            CountEmployees(from.Left);
            return(CountEmployees(from.Right));
        }
コード例 #16
0
 public int CountNodes(PositionNode from)
 {
     if (from == null)
     {
         return(count);
     }
     count++;
     CountNodes(from.Left);
     CountNodes(from.Right);
     return(count);
 }
コード例 #17
0
 public float SalaryPosition(PositionNode from, String certainPosition)
 {
     if (from == null)
     {
         return(0);
     }
     if (from.Position.Name == certainPosition)
     {
         return(from.Position.Salary);
     }
     return(SalaryPosition(from.Right, certainPosition) + SalaryPosition(from.Left, certainPosition));
 }
コード例 #18
0
 //How much is the salary given a certain position, Point 3
 public float salaryEmployee(PositionNode from, string name)
 {
     if (from == null)
     {
         return(0);
     }
     if (from.Position.Name == name)
     {
         return(from.Position.Salary);
     }
     return(salaryEmployee(from.Left, name) + salaryEmployee(from.Right, name));
 }
コード例 #19
0
        public float Count(PositionNode from)
        {
            if (from == null)
            {
                return(0);
            }

            float countLeft  = Count(from.Left);
            float countRight = Count(from.Right);

            return(countLeft + countRight + 1);
        }
コード例 #20
0
 //2,3
 public float SalaryForPosition(PositionNode from, string name)
 {
     if (from == null)
     {
         return(0);
     }
     if (from.Position.Name == name)
     {
         return(from.Position.Salary);
     }
     return(SalaryForPosition(from.Left, name) + SalaryForPosition(from.Right, name));
 }
コード例 #21
0
        public void printTree(PositionNode from)
        {
            if (from == null)
            {
                return;
            }

            Console.WriteLine($"{from.Position.Name} : ${from.Position.Salary}, Porcentaje: ${from.Position.Salary * from.Position.Porsentaje}");

            printTree(from.Left);
            printTree(from.Right);
        }
コード例 #22
0
        public void PrintTree(PositionNode node)
        {
            if (node == null)
            {
                return;
            }

            Console.WriteLine("{0,30} {1,10} {2,10} {3,10}", $"{node.Position.Name}:", $"{node.Position.Salary}", $"{node.Position.Percentage}", $"{node.Position.TaxValue}");


            PrintTree(node.Left);
            PrintTree(node.Right);
        }
コード例 #23
0
        //devuelve la cantidad de nodos de un arbol
        public int numberNodes(PositionNode from)
        {
            int nodes = 0;

            if (from != null)
            {
                nodes++;
                nodes += numberNodes(from.Left);
                nodes += numberNodes(from.Right);
            }

            return(nodes);
        }
コード例 #24
0
        //Method to print the tree from a node
        public void PrintTree(PositionNode from)
        {
            if (from == null)
            {
                return;
            }

            Console.WriteLine($"{from.Position.Name} : $ {from.Position.Salary}");

            //Recursive call to print left and right
            PrintTree(from.Left);
            PrintTree(from.Right);
        }
コード例 #25
0
        //Method of adding salaries
        public float AddSalaries(PositionNode from)
        {
            if (from == null)
            {
                return 0;
            }
            //Call recursive
            return from.Position.Salary + AddSalaries(from.Left) + AddSalaries(from.Right);

            //Recursive call to print left and right
            PrintTree(from.Left);
            PrintTree(from.Right);
        }
コード例 #26
0
 //2,1
 public void LongestSalary(PositionNode from)
 {
     if (from == null)
     {
         return;
     }
     if (from.Position != Root.Position && from.Position.Salary > countLongestSalary)
     {
         countLongestSalary = from.Position.Salary;
     }
     LongestSalary(from.Left);
     LongestSalary(from.Right);
 }
コード例 #27
0
        public void AddHigherSalary(PositionNode from)
        {
            if (from == null)
            {
                return;
            }

            if (from != Root)
            {
                if (from.Position.Salary > getHigherSalary())
                {
                    setHigherSalary(from.Position.Salary);
                }
            }
            AddHigherSalary(from.Left); AddHigherSalary(from.Right);
        }
コード例 #28
0
        public float specificSalarym(PositionNode from, String puesto)
        {
            if (from == null)
            {
                return(0);
            }
            else if (from.Position.Name.Equals(puesto))
            {
                specificSalary = from.Position.Salary;
            }

            specificSalarym(from.Left, puesto);
            specificSalarym(from.Right, puesto);

            return(specificSalary);
        }
コード例 #29
0
        public float higherSalarym(PositionNode from)
        {
            if (from == null)
            {
                return(0);
            }
            else if (from.Position.Salary > higherSalary && from.Position.Salary != 1000)
            {
                higherSalary = from.Position.Salary;
            }

            higherSalarym(from.Left);
            higherSalarym(from.Right);

            return(higherSalary);
        }
コード例 #30
0
        public void LongestSalary(PositionNode from)
        {
            if (from == null)
            {
                return;
            }
            if (from != Root)
            {
                if (from.Position.Salary > getLongestSal())
                {
                    setLongestSal(from.Position.Salary);
                }
            }

            LongestSalary(from.Left);
            LongestSalary(from.Right);
        }