Exemplo n.º 1
0
        private static Cocktail Build(CocktailKey key)
        {
            var recipe = BuildRecipe(key);
            var price  = CashController.GetPrice(key);

            return(new Cocktail(key, price, recipe));
        }
Exemplo n.º 2
0
        private static Dictionary <IngredientKey, int> BuildRecipe(CocktailKey key)
        {
            var recipe = new Dictionary <IngredientKey, int>();

            switch (key)
            {
            case CocktailKey.Mojito:
                recipe.Add(IngredientKey.Rum, 100);
                recipe.Add(IngredientKey.Lemon, 1);
                break;

            case CocktailKey.CubaLibre:
                recipe.Add(IngredientKey.Rum, 50);
                recipe.Add(IngredientKey.Cola, 50);
                recipe.Add(IngredientKey.Lemon, 1);
                break;

            case CocktailKey.Rum:
                recipe.Add(IngredientKey.Rum, 100);
                break;

            case CocktailKey.Cola:
                recipe.Add(IngredientKey.Cola, 100);
                break;

            case CocktailKey.Lemonade:
                recipe.Add(IngredientKey.Lemonade, 100);
                break;

            case CocktailKey.Custom:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(key), key, null);
            }

            return(recipe);
        }
Exemplo n.º 3
0
 internal Cocktail(CocktailKey key, decimal price, Dictionary <IngredientKey, int> recipe)
 {
     Key    = key;
     Price  = price;
     Recipe = recipe;
 }
Exemplo n.º 4
0
 public Sprite GetSprite(CocktailKey key)
 {
     return(_mapping.TryGetValue(key, out var sprite) ? sprite : null);
 }