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); }
public double TotalTaxes(PositionNode from) { if (from == null) { return(0); } return((from.Position.Salary * from.Position.tax) + TotalTaxes(from.Left) + TotalTaxes(from.Right)); }
public float AddSalaries(PositionNode from) { if (from == null) { return(0); } return(from.Position.Salary + AddSalaries(from.left) + AddSalaries(from.right)); }
public float addSalaries(PositionNode from) { if (from == null) { return(0); } return(from.Position.Salary + addSalaries(from.Left) + addSalaries(from.Right)); }
//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)); }
//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)); }
public float AddTax(PositionNode from) { if (from == null) { return(0); } return((from.Position.Salary * from.Position.Tax / 100) + AddTax(from.Left) + AddTax(from.Right)); }
public float SumSalaries(PositionNode node) { if (node == null) { return(0); } return(node.Position.Salary + SumSalaries(node.Left) + SumSalaries(node.Right)); }
public float SumTax(PositionNode node) { if (node == null) { return(0); } return(node.Position.TaxValue + SumTax(node.Left) + SumTax(node.Right)); }
public float Addsalaries2(PositionNode from) { if (from == null) { return(0); } return(from.Position.Salary + Addsalaries2(from.Left)); }
public float Addpromedios(PositionNode from) { if (from == null) { return(0); } return(from.Position.total + Addpromedios(from.Left) + Addpromedios(from.Right)); }
public float CalcNnodo(PositionNode from) { if (from == null) { return(0); } return(from.Position.NNodo + CalcNnodo(from.Left) + CalcNnodo(from.Right)); }
public void PrintTree(PositionNode from) { if (from == null) { return; } Console.WriteLine($"{from.Position.Name} : {from.Position.Salary}"); PrintTree(from.left); PrintTree(from.right); }
public int Node(PositionNode nodo) { if (nodo != null) { Node(nodo.Left); Node(nodo.Right); CountNodo++; } return(CountNodo); }
//2,2 public float CountEmployees(PositionNode from) { if (from == null) { return(count); } count++; CountEmployees(from.Left); return(CountEmployees(from.Right)); }
public int CountNodes(PositionNode from) { if (from == null) { return(count); } count++; CountNodes(from.Left); CountNodes(from.Right); return(count); }
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)); }
//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)); }
public float Count(PositionNode from) { if (from == null) { return(0); } float countLeft = Count(from.Left); float countRight = Count(from.Right); return(countLeft + countRight + 1); }
//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)); }
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); }
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); }
//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); }
//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); }
//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); }
//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); }
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); }
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); }
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); }
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); }