//public DateTime startDate //{ // get { return sDate; } // set { sDate = value.AddDays(rand.Next(1)); } //} //public DateTime endDate //{ // get { return sDate; } // set { eDate = value.AddDays(rand.Next(1, 10)); } //} public virtual void startBuilding(ref PartBuilding task) { //var countDay = rand.Next(1, 10); //int i = 1; //while (countDay != i) //{ // Console.Write(" . "); // i++; // Thread.Sleep(1000); //} //Console.WriteLine("Finished"); }
//{ // get // { // if (eDate!=null && eDate!=DateTime.MinValue) // { // return false; // } // else // { // return true; // } // } //} public override void startBuilding(ref PartBuilding task) { var countDay = rand.Next(1, 10); for (int i = 0; i < countDay; i++) { //Console.Write(" . "); Thread.Sleep(1000); } task.endDate = DateTime.Now.Date.AddDays(countDay); task.isDone = true; Console.WriteLine(""); Console.WriteLine("Завершил работу " + task.endDate); Console.WriteLine(""); Console.WriteLine(""); }
public void toDoWork(ref List <PartBuilding> tasks) { DateTime lastFisnishDate = DateTime.Now; if (tasks.Any(w => w.isDone)) { lastFisnishDate = tasks.Where(w => w.isDone).Max(m => m.endDate); } PartBuilding task = tasks.Where(w => !w.isDone).OrderBy(o => o.priority).Take(1).FirstOrDefault(); task.startDate = lastFisnishDate.AddDays(1); Console.WriteLine(String.Format("Начал работу {0} ({1}) по строительству {2}", lastFisnishDate, name, task.partName)); PartBuilding basem = new PartBuilding(); basem.startBuilding(ref task); }
static void Main(string[] args) { List <PartInfo> partInfo = new List <PartInfo>(); partInfo.Add(new PartInfo() { Count = 1, PartName = "Фундамент", Priority = 1 }); partInfo.Add(new PartInfo() { Count = 4, PartName = "Стена", Priority = 2 }); partInfo.Add(new PartInfo() { Count = 4, PartName = "Окно", Priority = 3 }); partInfo.Add(new PartInfo() { Count = 3, PartName = "Дверь", Priority = 4 }); partInfo.Add(new PartInfo() { Count = 1, PartName = "Крыша", Priority = 5 }); List <PartBuilding> tasks = new List <PartBuilding>(); foreach (var item in partInfo) { for (int i = 0; i < item.Count; i++) { PartBuilding p = new PartBuilding(); p.priority = item.Priority; p.partName = item.PartName; p.isDone = false; tasks.Add(p); } } // Team.workers.Add(new Worker("Stiff", Worker.positionList.Boss)); Team.workers.Add(new Worker("Ravshan")); Team.workers.Add(new Worker("Jamshut")); Team.workers.Add(new Worker("Bill")); Team.workers.Add(new Worker("Mark")); Team t = new Team(); t.StartWork(tasks); //Basement basem = new Basement(); //basem.startBuilding(DateTime.Now); //Worker kalib = new Worker("Калибшут"); //kalib.toDoWork(); //List<IPart> listOfWork = new List<IPart>(); //listOfWork.Add(new PartBuilding()); //listOfWork.Add(new Walls()); //listOfWork.Add(new Window()); //listOfWork.Add(new Door()); //listOfWork.Add(new Roof()); //for (int i = 1; i < 10; i++) //{ // Team.workers.Add(new Worker("Равшан"+i, "Негр")); //} //Console.WriteLine(Team.workers[3]); //Random rand = new Random(); //for (int i = 0; i < 50; i++) //{ // Team.workers[rand.Next(0, 9)].toDoWork(ref listOfWork); //} }