コード例 #1
0
ファイル: WayBillDay.cs プロジェクト: BBraunRussia/BBAuto
        private void Create(Random random)
        {
            SuppyAddressList suppyAddressList = SuppyAddressList.getInstance();
            SuppyAddress     suppyAddress     = suppyAddressList.getItemByRegion(_driver.Region.ID);

            if (suppyAddress == null)
            {
                throw new NullReferenceException("Не задан адрес подачи");
            }

            MyPoint currentPoint = suppyAddress.Point;

            RouteList routeList = RouteList.getInstance();

            int   residue = _count;
            Route route;

            do
            {
                int i = 0;

                do
                {
                    route = routeList.GetRandomItem(random, currentPoint);

                    if (i == 10)
                    {
                        break;
                    }
                    i++;
                }while (residue - route.Distance < 10);

                Add(route);
                residue -= Convert.ToInt32(route.Distance);

                currentPoint = route.MyPoint2;
            } while ((residue > 10) && (_routes.Count < 16));

            if (currentPoint != suppyAddress.Point)
            {
                route = routeList.GetItem(currentPoint, suppyAddress.Point);
                Add(route);
            }
        }