Пример #1
0
        static void Main(string[] args)
        {
            var foodFactory = new FoodFactory();
            var moodFactory = new MoodFactory();
            var foodList    = new List <Food>();

            var foodNames = Console.ReadLine().Split(' ');

            foreach (var foodName in foodNames)
            {
                string normalizedName = NormalizeName(foodName);
                var    food           = foodFactory.ProduceFood(normalizedName);
                foodList.Add(food);
            }

            int totalHappiness = foodList.Sum(f => f.HappinessPoints);
            var mood           = moodFactory.ProduceMood(totalHappiness);

            Console.WriteLine(totalHappiness);
            Console.WriteLine(mood.Name);

            Console.ReadKey();
        }
Пример #2
0
        static void Main(string[] args)
        {
            List <Food> foodsEaten  = new List <Food>();
            FoodFactory foodFactory = new FoodFactory();
            MoodFactory moodFactory = new MoodFactory();

            string[] foods = Console.ReadLine().Split();

            foreach (var food in foods)
            {
                Food foodToAdd = foodFactory.GetFood(food);

                foodsEaten.Add(foodToAdd);
            }

            int happinesFood = foodsEaten
                               .Select(x => x == null ? -1 : x.Happiness)
                               .Sum();

            Mood happinesMood = moodFactory.GetMood(happinesFood);

            Console.WriteLine(happinesFood);
            Console.WriteLine(happinesMood.GetType().Name);
        }
Пример #3
0
        public void Eat(string foodName)
        {
            Food food = FoodFactory.MakeFood(foodName);

            HappinessPoints += food.HappinessPoints;
        }