Ejemplo n.º 1
0
        public string MultiplyCount(int weight)
        {
            var values = new List <Ingredients>();
            int cost = 0, quant = 0;

            foreach (var t in OptimizedData.MultiplyItems)
            {
                values.AddRange(t.Ingredient);
                cost  += t.Cost;
                quant += t.Quantity;
            }
            Func <Ingredients, double> linq = t => t.Rank * t.Part / OptimizedData.MultiplyItems.Count;

            return(@"Ваша доза опьянения -" +
                   $" {MedicalFormules.Calculator(values, weight, quant, OptimizedData.MultiplyItems.Count, linq)}‰" +
                   $"\nВы потратили - {cost} грн.");
        }
Ejemplo n.º 2
0
 public void FindOptimizedAlcohol(
     int weight,
     bool isChecked,
     string currentMoney)
 {
     User.Items.Clear();
     foreach (var t in new FormPointers(_sqLiteConnection).CoctailsRepository.GetAll())
     {
         User.Items.Add(new User
         {
             Ingredient = t.Ingredient,
             Name       = t.Name,
             Quantity   = t.Quantity,
             Weight     = weight,
             Promille   = MedicalFormules.Calculator(t.Ingredient, weight, t.Quantity, 1, a => a.Part * a.Rank),
             Cost       = t.Cost
         });
     }
     OptimizedData.DisplayCost = Algorithm(isChecked ? Convert.ToInt32(currentMoney) : 0, weight, isChecked);
 }
Ejemplo n.º 3
0
        public double Algorithm(int fullMoneyEquivalent, int weight, bool isChecked)
        {
            var values = new List <Ingredients>();

            OptimizedData.PrimaryItems.Clear();
            OptimizedData.PrimaryItems = User.Items
                                         .OrderBy(s => - s.Promille)
                                         .ThenBy(s => s.Cost)
                                         .ToList();
            int quant = 0, cost = 0;

            foreach (var t in OptimizedData.PrimaryItems)
            {
                if (!OptimizedData.PrimaryItems.Any(v => fullMoneyEquivalent <= v.Cost))
                {
                    quant += t.Quantity;
                    cost  += t.Cost;
                    OptimizedData.SecondaryItems.Add(t);
                    fullMoneyEquivalent -= t.Cost;
                }
                else
                {
                    break;
                }
            }
            foreach (var s in OptimizedData.SecondaryItems)
            {
                values.AddRange(s.Ingredient);
            }
            OptimizedData.DisplayInxtoxication =
                TypeOfAlcoholIntoxication(MedicalFormules.Calculator(values, weight, quant,
                                                                     OptimizedData.SecondaryItems.Count,
                                                                     t => t.Rank * t.Part / OptimizedData.SecondaryItems.Count));
            OptimizedData.DisplayAssembly = DisAssembly(values, t => t.Rank > 0);
            return(cost);
        }