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