Esempio n. 1
0
        /// <summary>
        /// Creates a new recipe
        /// </summary>
        /// <returns>The recipe or null if aborted</returns>
        private static Recipe CreateRecipe()
        {
            Console.Clear();
            RecipeView.RenderHeader("          Nytt recept          ");
            string name = ReadRecipeName();
            if (name == null) {
                return null;
            }

            Recipe recipe = new Recipe(name);

            List<Ingredient> ingredients = ReadIngredients();
            if (ingredients == null) {
                return null;
            }
            foreach (Ingredient ingredient in ingredients) {
                recipe.Add(ingredient);
            }

            List<string> directions = ReadDirections();
            if (directions == null) {
                return null;
            }
            foreach (string direction in directions) {
                recipe.Add(direction);
            }

            return recipe;
        }
Esempio n. 2
0
 public void SetRecipe()
 {
     Recipes.Add(new List <int>()
     {
         1, 2, 3
     }, 10);
 }
 /// <summary>
 /// add a recipe item which is needed to craft this item
 /// </summary>
 /// <param name="item">the referenc to the item</param>
 /// <param name="quantity">the amount which is needed for the craft</param>
 public void AddRecipeItem(FactorioItem item, int quantity)
 {
     if (!Recipe.ContainsKey(item))
     {
         Recipe.Add(item, quantity);
     }
 }
Esempio n. 4
0
 public ChocolateMilk() : base(name, image, price)
 {
     //load the recipe.
     //it't initialized in the base class.
     Recipe.Add(Enums.IngredientsEnum.ChocolatePowder, 25);
     Recipe.Add(Enums.IngredientsEnum.Milk, 100);
 }
Esempio n. 5
0
 public Americano() : base(name, image, price)
 {
     //load the recipe.
     //it't initialized in the base class.
     Recipe.Add(Enums.IngredientsEnum.CoffeeBeans, 30);
     Recipe.Add(Enums.IngredientsEnum.Water, 100);
 }
Esempio n. 6
0
 public Tea() : base(name, image, price)
 {
     //load the recipe.
     //it't initialized in the base class.
     Recipe.Add(Enums.IngredientsEnum.TeaLeaves, 20);
     Recipe.Add(Enums.IngredientsEnum.Water, 200);
 }
Esempio n. 7
0
 public Cappuccino() : base(name, image, price)
 {
     //load the recipe.
     //it't initialized in the base class.
     Recipe.Add(Enums.IngredientsEnum.CoffeeBeans, 25);
     Recipe.Add(Enums.IngredientsEnum.Milk, 100);
 }
Esempio n. 8
0
        private void OnAddClick(object sender, RoutedEventArgs e)
        {
            var recipeItem = new RecipeItem
            {
                Count = 1
            };
            var window = new RecipeItemWindow(recipeItem, _project)
            {
                Owner = this
            };

            if (window.ShowDialog() == true)
            {
                _recipe.Add(recipeItem);
                _recipeItems.Add(recipeItem);
            }
        }
Esempio n. 9
0
 public void Init()
 {
     recipe = new Recipe("przepis na naleśniki");
     unit   = new Unit("gram", 'g', 1);
     recipe.Add(new Ingredient("mąka", 240), unit);
     recipe.Add(new Ingredient("sól", 288), unit);
     recipe.Add(new Ingredient("mleko", 250), unit);
     recipe.Add(new Ingredient("jajka", 278), unit);
     water = new Ingredient("woda", 278);
     recipe.Add(water, unit);
     recipe.Add(new Ingredient("masło", 240), unit);
 }
        public virtual void Load()
        {
            List<IRecipe> recipesList = new List<IRecipe>();
            RecipeReadStatus status = new RecipeReadStatus();
            Recipe recipe = null;

            using (StreamReader loadedRecipe = new StreamReader(_path))
            {
                string line;
                while ((line = loadedRecipe.ReadLine()) != null)
                {
                    if (line == SectionRecipe)
                    {
                        status = RecipeReadStatus.New;
                    }
                    else if (line == SectionIngredients)
                    {
                        status = RecipeReadStatus.Ingredient;
                    }
                    else if (line == SectionInstructions)
                    {
                        status = RecipeReadStatus.Instruction;
                    }
                    else
                    {
                        switch (status)
                            {
                                case RecipeReadStatus.Indefinite:
                                    throw new FileFormatException();
                                case RecipeReadStatus.New:
                                    recipe = new Recipe(line);
                                    recipesList.Add(recipe);
                                    break;
                                case RecipeReadStatus.Ingredient:
                                    string[] ingredientArray = line.Split(new char[] { ';' } );
                                    if (ingredientArray.Length != 3)
                                    {
                                        throw new FileFormatException();
                                    }
                                    Ingredient ingredient = new Ingredient();
                                    ingredient.Amount = ingredientArray[0];
                                    ingredient.Measure = ingredientArray[1];
                                    ingredient.Name = ingredientArray[2];
                                    recipe.Add(ingredient);
                                    break;
                                case RecipeReadStatus.Instruction:
                                    if (line.Length > 0)
                                    {
                                        recipe.Add(line);
                                    }
                                    break;
                            }
                    }
                    recipesList.Sort();
                    _recipes = recipesList;
                    IsModified = false;
                    OnRecipesChanged(EventArgs.Empty);
                }
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Loads recipes from the file specified at Path
        /// </summary>
        /// <returns>A list of recipes</returns>
        public List<Recipe> Load()
        {
            RecipeReadStatus status = RecipeReadStatus.Indefinite;
            string[] lines = System.IO.File.ReadAllLines(Path);
            Recipe recipe = null;
            List<Recipe> recepies = new List<Recipe>();

            foreach (string line in lines) {
                if (String.IsNullOrWhiteSpace(line)) {
                    continue;
                } else if (line == "[Recept]") {
                    status = RecipeReadStatus.New;
                    continue;
                } else if (line == "[Ingredienser]") {
                    status = RecipeReadStatus.Ingredient;
                    continue;
                } else if (line == "[Instruktioner]") {
                    status = RecipeReadStatus.Direction;
                    continue;
                }

                try {
                    switch (status) {
                        case RecipeReadStatus.New:
                            recipe = new Recipe(line);
                            recepies.Add(recipe);
                            break;
                        case RecipeReadStatus.Ingredient:
                            Ingredient i = new Ingredient();
                            string[] parts = line.Split(';');

                            if (parts.Length != 3) {
                                throw new Exception("bad file format");
                            }

                            i.Amount = parts[0];
                            i.Measure = parts[1];
                            i.Name = parts[2];

                            recipe.Add(i);
                            break;
                        case RecipeReadStatus.Direction:
                            recipe.Add(line);
                            break;
                        default:
                            throw new Exception("bad file format");
                    }
                } catch (NullReferenceException) {
                    throw new Exception("bad file format");
                }
            }

            recepies.Sort();

            return recepies;
        }