//------ public override AbstractEmployee getChild() { bool found; AbstractEmployee tEmp = null; IEnumerator esub; if (getName().Equals(getName())) { return(this); } else { found = false; esub = subordinates.GetEnumerator(); while (!found && esub.MoveNext()) { tEmp = (AbstractEmployee)esub.Current; found = (tEmp.getName().Equals(name)); if (!found) { if (!tEmp.isLeaf()) { tEmp = tEmp.getChild(); found = (tEmp.getName().Equals(name)); } } } if (found) { return(tEmp); } else { return(new Employee(null, "New person", 0)); } } }
private void btShowBoss_Click(object sender, System.EventArgs e) { EmpNode node; node = (EmpNode)EmpTree.SelectedNode; AbstractEmployee emp = node.getEmployee(); string bosses = ""; while (emp != null) { bosses += emp.getName() + "\n"; emp = emp.getBoss(); } MessageBox.Show(null, bosses, "Reporting chain"); }
public EmpNode(AbstractEmployee aemp) : base(aemp.getName()) { emp = aemp; }
//------ public Boss(AbstractEmployee parnt, AbstractEmployee emp) : base(parnt, emp.getName(), emp.getSalary()) { }