Пример #1
0
        public double GetTotalCost(TeamLeader tl)
        {
            List <IPart> parts = new List <IPart>();

            parts.AddRange(this.Basement);
            parts.AddRange(this.Walls);
            parts.AddRange(this.Roof);
            return(parts.Select(part => part.worker.Salary * part.worker.EmploymentPeriod).Sum() + (tl.Salary * tl.EmploymentPeriod));
        }
Пример #2
0
        public void StartBuild()
        {
            House house = CreateHouse();
            Team  team  = new Team();

            team.CreateWorkers(5);

            foreach (IPart part in GetUndone(house))
            {
                var worker = team.GetWorker();
                if (worker is TeamLeader)
                {
                    house.PrintReport();
                }
                else
                {
                    part.worker              = worker;
                    part.Status              = true;
                    worker.EmploymentPeriod += part.TimeToCreate;
                    worker.ShowState(part);
                    for (int i = 0; i < part.TimeToCreate; i++)
                    {
                        Console.Write(".");
                        Thread.Sleep(100);
                    }

                    Console.WriteLine("");
                }
            }
            double     temp  = team.workers.Where(p => p is Worker).Max(w => w.EmploymentPeriod);
            TeamLeader templ = team.GetTL() as TeamLeader;

            templ.EmploymentPeriod = temp;
            house.TotalCost        = house.GetTotalCost(templ);
            house.PrintReport();
        }
Пример #3
0
        public void CreateWorkers(int count)
        {
            Random rnd = new Random();

            for (int i = 0; i < count; i++)
            {
                IWorker worker = new Worker();
                string  Name   = "Worker: ".GenerateName();
                while (workers.Any(p => p.Name == Name))
                {
                    Name = "Worker: ".GenerateName();
                }
                worker.Name   = Name;
                worker.Age    = rnd.Next(18, 45);
                worker.Salary = rnd.Next(45000, 200000);
                this.workers.Add(worker);
            }
            IWorker team = new TeamLeader();

            team.Name   = "Name TL";
            team.Age    = 55;
            team.Salary = 120000;
            this.workers.Add(team);
        }