private static void Main(string[] args) { var foodNames = Console.ReadLine().ToLower().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); List <Food> foods = new List <Food>(); var ff = new FoodFactory(); foreach (var name in foodNames) { foods.Add(ff.CreateFood(name)); } Gandalf gandalf = new Gandalf(foods); Console.WriteLine(gandalf.ToString()); }
static void Main(string[] args) { Gandalf gandalf = new Gandalf(); var foodFactory = new FoodFactory(); var input = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); foreach (var f in input) { var food = foodFactory.CreateFood(f); gandalf.Eat(food); } MoodFactory mood = new MoodFactory(); Console.WriteLine(gandalf.TotalPoints); Console.WriteLine(mood.CreateMood(gandalf.TotalPoints).Name); }
static void Main(string[] args) { Gandalf gandalf = new Gandalf(); string input = Console.ReadLine(); if (input.Length > 1000) { throw new Exception("The characters in the input string will be no more than: 1000"); } string[] foods = input.Split(" ", StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < foods.Length; i++) { gandalf.Eat(FoodFactory.Create(foods[i])); } Console.WriteLine(gandalf.Happiness); Console.WriteLine(gandalf.Mood.Name); Console.ReadKey(); }
public static void Main() { string[] foodsNames = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray(); List <Food> foods = new List <Food>(); for (int i = 0; i < foodsNames.Length; i++) { Food food = FoodFactory.CreateFood(foodsNames[i].ToLower()); foods.Add(food); } Mood mood = MoodFactory.CreateMood(foods); Gandalf gandalf = new Gandalf(foods, mood); Console.WriteLine(gandalf); }
public static void Main() { var gandalf = new Gandalf(); var foodFactory = new FoodFactory(); Console.ReadLine() .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .ToList() .ForEach(f => { var food = foodFactory.CreateFood(f); gandalf.Eat(food); }); Console.WriteLine(gandalf.TotalPointsOfHappiness); MoodFactory moodFactory = new MoodFactory(); Console.WriteLine(moodFactory.CreateMood(gandalf.TotalPointsOfHappiness).Name); }
public static void Main() { var foodFactory = new FoodFactory(); var moodFactory = new MoodFactory(); var inputFoods = Console.ReadLine() .Split(new char[] { ' ', '\t', '\n' }, StringSplitOptions.RemoveEmptyEntries); var gandi = new Gandalf(); foreach (var foodstring in inputFoods) { var food = foodFactory.GetFood(foodstring); gandi.Eat(food); } var totalhappines = gandi.GetHappinessPoints(); var mood = moodFactory.GetMood(totalhappines); Console.WriteLine(totalhappines); Console.WriteLine(mood); }
public static void Main() { var foodFactory = new FoodFactory(); var moodFactory = new MoodFactory(); var inputFood = Console.ReadLine().Split(new[] { ' ', '\t', '\n' }, StringSplitOptions.RemoveEmptyEntries); var gandalf = new Gandalf(); foreach (var food in inputFood) { gandalf.Eat(foodFactory.GetFood(food)); } var hapiness = gandalf.GetHappinessPoints(); var currentMood = moodFactory.GetMood(hapiness); Console.WriteLine(hapiness); Console.WriteLine(currentMood); }
static void Main() { var foodFactory = new FoodFactory(); var moodFactory = new MoodFactory(); var gandalf = new Gandalf(); string[] inputFood = Console.ReadLine().Split(new[] { ' ', '\t', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var food in inputFood) { Food foodEaten = foodFactory.GetFood(food); gandalf.Eat(foodEaten); } int totalHappinessPoints = gandalf.GetHappinessPoints(); Mood currentMood = moodFactory.GetMood(totalHappinessPoints); Console.WriteLine(totalHappinessPoints); Console.WriteLine(currentMood); }
private void Button_Click(object sender, RoutedEventArgs e) { gandalf = new Gandalf(); gandalf.Eat(str.Split().Where(fn => fn != String.Empty).Select(fn => FoodFactory.GetFood(fn))); Mood.Content = gandalf; }