static void Main(string[] args) { string[] foodNames = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); List <Food> foods = new List <Food>(); foreach (var food in foodNames) { Food newFood = FoodFactory.GetFood(food); foods.Add(newFood); } var gandalf = new Gandalf(); gandalf.Eat(foods); Console.WriteLine(gandalf); }
public static void Main() { var foodFactory = new FoodFactory(); var moodFactory = new MoodFactory(); var gandalf = new Gandalf(); var inputFood = Console.ReadLine().Split(new[] { '\t', ' ', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var foodStr in inputFood) { Food food = foodFactory.GetFood(foodStr); gandalf.Eat(food); } int totalHapinessPoints = gandalf.GetHapinessPoints(); Mood currentMood = moodFactory.GetMood(totalHapinessPoints); Console.WriteLine(totalHapinessPoints); Console.WriteLine(currentMood); }