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

            return(ingredients);
        }
Beispiel #6
0
 public void AddIngredients(string[] ingredients)
 {
     Occurances++;
     foreach (var ing in ingredients)
     {
         if (IngredientsCount.ContainsKey(ing))
         {
             IngredientsCount[ing] += 1;
         }
         else
         {
             IngredientsCount[ing] = 1;
         }
     }
 }
Beispiel #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);
        }