Exemple #1
0
        public void CreateBreakfast()
        {
            int good = 0;

            while (good == 0)
            {
                Dish   dish1, dish2;
                Random rnd   = new Random();
                int    first = rnd.Next(0, 10000000);
                first = first % DishList.LengthListDish(0);
                dish1 = DishList.GetDish(0, first);
                int second = rnd.Next(0, 10000000);
                second = second % DishList.LengthListDish(1);
                dish2  = DishList.GetDish(1, second);
                double calories = 0.85 * 3 / 8 * _human.Calories;
                double weight1, weight2;
                weight1 = calories * 0.7 / dish1.Calories * 100;
                weight2 = calories * 0.3 / dish2.Calories * 100;
                if ((weight1 < _kashaWeight[1]) && (weight1 > _kashaWeight[0]) && (weight2 < _zakuskaWeight[1]) &&
                    (weight2 > _zakuskaWeight[0]))
                {
                    good         = 1;
                    dish1.Weight = Math.Round(weight1, MidpointRounding.AwayFromZero);
                    dish2.Weight = Math.Round(weight2, MidpointRounding.AwayFromZero);
                    MenuList.AddDish(dish1, 0);
                    MenuList.AddDish(dish2, 0);
                }
            }
        }
        public DishList GeDishList()
        {
            DishList      dishList = new DishList(DishType.Length);
            SQLiteCommand cmd      = Db.CreateCommand();

            for (int i = 0; i < DishType.Length; i++)
            {
                cmd.CommandText = "select * from Dish where type ='" + DishType[i] + "'";
                SQLiteDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Dish dish = new Dish(reader["Name"].ToString().ToUpper(), Convert.ToDouble(reader["Proteins"]), Convert.ToDouble(reader["Fats"]), Convert.ToDouble(reader["Carbohydrates"]), Convert.ToDouble(reader["Calories"]));
                    dishList.AddDish(dish, i);
                }
                reader.Close();
            }
            return(dishList);
        }