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

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