Exemple #1
0
 public static Either <string, IngredientsCount> Wrap(IngredientsCount ingredients)
 {
     return(new IngredientsCount
     {
         AppleCount = $@"{ingredients.AppleCount};+wrapping for N apples;"
     });
 }
Exemple #2
0
 public static Either <string, IngredientsCount> AddToffee(IngredientsCount ingredients)
 {
     return(new IngredientsCount
     {
         AppleCount = $@"{ingredients.AppleCount}; +toffee for N apples "
     });
 }
Exemple #3
0
 public static ToffeeAppleProduct toToffeeAppleProduct(IngredientsCount ingredients)
 {
     return(new ToffeeAppleProduct
     {
         ApplesCount = ingredients.ApplesCount,
     });
 }
Exemple #4
0
 public static Either <string, IngredientsCount> Prep(IngredientsCount ingredients)
 {
     return(new IngredientsCount
     {
         AppleCount = ingredients.AppleCount.Trim(),
         ApplesCount = Convert.ToInt32(ingredients.AppleCount.Trim()),
     });
 }
Exemple #5
0
        private Either <string, IngredientsCount> CreateToffeeAppleRequestForStringQ(string appleCount)
        {
            Either <string, IngredientsCount> ingredients =
                new IngredientsCount
            {
                AppleCount = appleCount
            };

            return(ingredients);
        }
 public void AddIngredients(string[] ingredients)
 {
     Occurances++;
     foreach (var ing in ingredients)
     {
         if (IngredientsCount.ContainsKey(ing))
         {
             IngredientsCount[ing] += 1;
         }
         else
         {
             IngredientsCount[ing] = 1;
         }
     }
 }
Exemple #7
0
        public static Either <string, IngredientsCount> Validate(IngredientsCount ingredientsCount)
        {
            if (string.IsNullOrWhiteSpace(ingredientsCount.AppleCount))
            {
                return("is null or empty!");
            }

            try
            {
                var appleCount = Convert.ToInt32(ingredientsCount.AppleCount.Trim());
            }
            catch
            {
                return("AppleCount cannot be converted to a number!");
            }

            return(ingredientsCount);
        }