private decimal Pay( IOrganizationUnit unit, decimal paid, int depth) { foreach (var dep in unit.Subunits) { paid += this.Pay(dep, 0, depth + 1); } foreach (var emp in unit.Employees) { decimal percents = (15 - depth) * 0.01m; paid += emp.RecieveSalary(percents, this.ceo.Salary); } this.output.Insert(0, string.Format("{0}{1} ({2:f2})\n", new String(' ', depth * 4), unit.Name, paid ) ); return paid; }
public static IEmployee CreateEmployee ( string firstName, string lastName, string position, IOrganizationUnit inUnit, decimal salary = 0 ) { switch (position) { case "CEO": return new CEO(firstName, lastName, inUnit, salary) ; case "Manager": return new Manager(firstName, lastName, inUnit); case "Regular": return new Regular(firstName, lastName, inUnit); case "ChiefTelephoneOfficer": return new ChiefTelephoneOfficer(firstName, lastName, inUnit); case "CleaningLady": return new CleaningLady(firstName, lastName, inUnit); case "Salesman": return new Salesman(firstName, lastName, inUnit); case "Accountant": return new Accountant(firstName, lastName, inUnit); default: throw new ArgumentException("Unknoun type employee!"); } }
public Employee( string firsrName, string lastName, IOrganizationUnit inUnit, decimal salaryFactor) { this.FirstName = firsrName; this.LastName = LastName; this.InUnit = inUnit; this.SalaryFactor = salaryFactor; }
public Regular(string firstName, string lastName, IOrganizationUnit inUnit) : base(firstName, lastName, inUnit, RegularSalaryFactor) { }
public Accountant(string firstName, string lastName, IOrganizationUnit inUnit) : base(firstName, lastName, inUnit, AccountantSalaryFactor) { }
public void AddSubunits(IOrganizationUnit subunit) { this.subunits.Add(subunit); }
public void AddCompany(IOrganizationUnit company) { this.companies.Add(company); }
public CEO(string firstName, string lastName, IOrganizationUnit inUnit, decimal salary) :base(firstName, lastName, inUnit, CEOSalaryFactor) { this.Salary = salary; }
public Salesman(string firstName, string lastName, IOrganizationUnit inUnit) : base(firstName, lastName, inUnit, SalesmanSalaryFactor) { }
public ChiefTelephoneOfficer(string firstName, string lastName, IOrganizationUnit inUnit) : base(firstName, lastName, inUnit, ChiefTelephoneOfficerSalaryFactor) { }
public Manager(string firstName, string lastName, IOrganizationUnit inUnit) : base(firstName, lastName, inUnit, ManagerSalaryFactor) { }
public CleaningLady(string firstName, string lastName, IOrganizationUnit inUnit) : base(firstName, lastName, inUnit, CleaningLadySalaryFactor) { }