Esempio n. 1
0
        /// <summary>
        /// 配置を行う
        /// </summary>
        /// <param name="EachDay"></param>
        /// <param name="member"></param>
        /// <returns></returns>
        internal bool Allocation(Day EachDay, Member member)
        {
            //カレントの曜日の清掃箇所ランダムリストを回す
            foreach (var CleaningPart in EachDay.place)
            {
                //割り当てオブジェクト作成
                Day today = new Day();
                //曜日を設定
                today.days = EachDay.days;
                if (EachDay.days == ContractConst.DAYS.金)
                {
                    System.Diagnostics.Debug.WriteLine("");
                }

                //清掃箇所のランダムキューに値が存在する間ループを回す
                if (CleaningPart.value.Count > 0)
                {
                    //先頭の清掃箇所を取得
                    int? randamPlaceValue = CleaningPart.value.Dequeue();
                    //清掃可否判定を行う
                    if (CheckCleanable(member, randamPlaceValue, today.days))
                    {
                        //担当箇所オブジェクト作成
                        Place ResponsiblePlace = new Place();
                        //同日内清掃箇所リストに追加
                        ResponsiblePlace.value.Enqueue(randamPlaceValue);
                        //カレントの曜日の清掃箇所を決定
                        today.place.Add(ResponsiblePlace);
                        //得点を足しこむ
                        if (randamPlaceValue == null)
                        {
                            member.Score += 0;
                        }
                        else
                        {
                            member.Score += ContractConst.COEFFICIENT[(int)randamPlaceValue];
                        }
                        member.day.Add(today);
                        member.Info += today.days.ToString() + randamPlaceValue.ToString() + " ";
                    }
                    else
                    {
                        CleaningPart.value.Enqueue(randamPlaceValue);
                    }
                }
                else
                {
                    return false;
                }
            }
            return true;
        }
Esempio n. 2
0
 /// <summary>
 /// 曜日単位のデータを作成
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 private Day DayLoccation(int[] p)
 {
     Day day = new Day();
     Place place = new Place();
     while (place.value.Count() < p.Count())
     {
         System.Random rng = new System.Random();
         int k = rng.Next(p.Count());
         int num = p[k];
         if (!place.value.Contains(num))
         {
             place.value.Enqueue(p[k]);
         }
     }
     day.place.Add(place);
     return day;
 }