Exemple #1
0
        public void LoadVanForCity(Van van, City city)
        {
            foreach (var pair in city.Prices.OrderByDescending((x) => x.Value))
            {
                string item   = pair.Key;
                double amount = this.stock[item];

                if (amount > van.RemainingCapacity)
                {
                    amount = van.RemainingCapacity;
                }

                if (amount > 0)
                {
                    van.Load(item, amount);
                }
            }

            var profit = van.Contents.GetProfitForCity(city);

            if (profit > ProfitForBestCity)
            {
                BestCity            = city;
                RevenueForBestCity  = van.Contents.GetRevenueForCity(city);
                ProfitForBestCity   = profit;
                ItemsSoldAtBestCity = van.Contents;
            }
        }
Exemple #2
0
 public void SelectBestCity(ICollection <City> cities)
 {
     foreach (City city in cities)
     {
         Van van = new Van(200);
         LoadVanForCity(van, city);
     }
 }
Exemple #3
0
 public void SelectBestCity(ICollection<City> cities)
 {
     foreach (City city in cities)
     {
         Van van = new Van(200);
         LoadVanForCity(van, city);
     }
 }
Exemple #4
0
        public void OptimalLoadForOneCity(string cityName, double expectedRevenue, double expectedProfit)
        {
            var city = cityIndex[cityName];
            var van  = new Van(200);

            this.optimizer.LoadVanForCity(van, city);
            this.optimizer.DumpResult();

            Assert.That(this.optimizer.BestCity.Name, Is.EqualTo(city.Name));
            Assert.That(this.optimizer.RevenueForBestCity, Is.EqualTo(expectedRevenue));
            Assert.That(this.optimizer.ProfitForBestCity, Is.EqualTo(expectedProfit));
        }
Exemple #5
0
        public void LoadVanForCity(Van van, City city)
        {
            foreach (var pair in city.Prices.OrderByDescending((x) => x.Value))
            {
                string item = pair.Key;
                double amount = this.stock[item];

                if (amount > van.RemainingCapacity)
                    amount = van.RemainingCapacity;

                if (amount > 0)
                    van.Load(item, amount);
            }

            var profit = van.Contents.GetProfitForCity(city);
            if (profit > ProfitForBestCity)
            {
                BestCity = city;
                RevenueForBestCity = van.Contents.GetRevenueForCity(city);
                ProfitForBestCity = profit;
                ItemsSoldAtBestCity = van.Contents;
            }
        }
Exemple #6
0
 public void CreateVan()
 {
     this.van = new Van(200);
 }
Exemple #7
0
 public void CreateVan()
 {
     this.van = new Van(200);
 }