Пример #1
0
 public PeterParker(PeterParker parent, ParkingType type)
 {
     parkings = new List <Parking>(parent.parkings);
     parkings.Add(new Parking(type));
     totalLength = parent.totalLength;
     //baseCurve = parent.baseCurve;
 }
Пример #2
0
        public void Add(PeterParker parker)
        {
            if (collection.Count < 10)
            {
                collection.Add(parker);
                Sort();
            }

            else
            {
                if (collection[0].ParkingUnitCount().Sum() < parker.ParkingUnitCount().Sum())
                {
                    collection.RemoveAt(0);
                    collection.Add(parker);
                    Sort();
                }
            }
        }
Пример #3
0
        public static ParkingResult Calculate(double initialLength /*, Curve initialCurve*/)
        {
            PeterParker           origin = new PeterParker(initialLength /*, initialCurve*/);
            Queue <PeterParker>   wait   = new Queue <PeterParker>();
            PeterParkerCollection fit    = new PeterParkerCollection();

            wait.Enqueue(origin);

            while (wait.Count > 0)
            {
                PeterParker current = wait.Dequeue();
                for (int i = 0; i < (int)ParkingType.Max; i++)
                {
                    PeterParker temp = new PeterParker(current, (ParkingType)i);
                    if (temp.LeftLength() < 0)
                    {
                        //cull
                    }
                    else if (temp.LeftLength() > 0)
                    {
                        if (temp.LeftLength() < 5)
                        {
                            //fit
                            fit.Add(temp);
                        }
                        else
                        {
                            //re enqueue
                            wait.Enqueue(temp);
                        }
                    }
                }
            }

            //

            fit.collection.ForEach(n => n.FillRoads());
            var result = new ParkingResult(fit);

            return(result);
        }