Ejemplo n.º 1
0
        public Statistic SimulateWihFifeShips(double fullTime)
        {
            var timeScale = 0.0;
            var shipQueue = new ShipQueue();
            var storm     = new Storm();
            var toWork    = new ToWork();
            var fifeShips = new FiveShips();
            var statistic = new Statistic(4);

            IQuest[] quests = { shipQueue, storm, toWork, fifeShips };

            shipQueue.Init(toWork);
            toWork.Init(shipQueue, storm, statistic, fifeShips);
            fifeShips.Init(shipQueue);

            while (timeScale < fullTime)
            {
                Array.Sort(quests);
                for (int i = 0; i < quests.Length; i++)
                {
                    if (quests[i].EndTime > timeScale)
                    {
                        timeScale = quests[i].EndTime;
                    }
                    if (quests[i].TryMake(timeScale))
                    {
                        break;
                    }
                }
            }
            return(statistic);
        }
Ejemplo n.º 2
0
 public void Init(ShipQueue shipQueue, Storm storm, Statistic statistic, FiveShips fifeShips)
 {
     this.shipQueue = shipQueue;
     this.storm     = storm;
     this.statistic = statistic;
     this.fifeShips = fifeShips;
 }