Exemple #1
0
        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;
        }
Exemple #2
0
 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!");
     }
 }
Exemple #3
0
 public Employee(
     string firsrName,
     string lastName,
     IOrganizationUnit inUnit,
     decimal salaryFactor)
 {
     this.FirstName = firsrName;
     this.LastName = LastName;
     this.InUnit = inUnit;
     this.SalaryFactor = salaryFactor;
 }
Exemple #4
0
 public Regular(string firstName, string lastName, IOrganizationUnit inUnit)
     : base(firstName, lastName, inUnit, RegularSalaryFactor)
 {
 }
Exemple #5
0
 public Accountant(string firstName, string lastName, IOrganizationUnit inUnit)
     : base(firstName, lastName, inUnit, AccountantSalaryFactor)
 {
 }
Exemple #6
0
 public void AddSubunits(IOrganizationUnit subunit)
 {
     this.subunits.Add(subunit);
 }
Exemple #7
0
 public void AddCompany(IOrganizationUnit company)
 {
     this.companies.Add(company);
 }
Exemple #8
0
 public CEO(string firstName, string lastName, IOrganizationUnit inUnit, decimal salary)
     :base(firstName, lastName, inUnit, CEOSalaryFactor)
 {
     this.Salary = salary;
 }
Exemple #9
0
 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)
 {
 }
Exemple #11
0
 public Manager(string firstName, string lastName, IOrganizationUnit inUnit)
     : base(firstName, lastName, inUnit, ManagerSalaryFactor)
 {
 }
Exemple #12
0
 public CleaningLady(string firstName, string lastName, IOrganizationUnit inUnit)
     : base(firstName, lastName, inUnit, CleaningLadySalaryFactor)
 {
 }