Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Gandalf gand = new Gandalf();

            gand.Eat(Console.ReadLine().Split().Where(fn => fn != string.Empty).Select(fn => FoodFactory.GetFood(fn)));
            Console.WriteLine(gand);
        }
Ejemplo n.º 2
0
    public static void Main()
    {
        var gandalf = new Gandalf();

        gandalf.Eat(Console.ReadLine());
        Console.WriteLine(gandalf.HppinessPoints);
        Console.WriteLine(gandalf.Mood());
    }
    public static void Main()
    {
        var input   = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        var gandalf = new Gandalf();

        foreach (var str in input)
        {
            var food = FoodFactory.ProduceFood(str);
            gandalf.Eat(food);
        }

        Console.WriteLine(gandalf);
    }
        private static void Main()
        {
            var food = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            var gandalf = new Gandalf();

            foreach (var s in food)
            {
                var f = FoodFactory.ProduceFood(s);
                gandalf.Eat(f);
            }

            Console.WriteLine(gandalf);
        }
Ejemplo n.º 5
0
    static void Main(string[] args)
    {
        var input = Console.ReadLine()
                    .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                    .ToList();

        var gandalf = new Gandalf();

        for (int i = 0; i < input.Count; i++)
        {
            gandalf.Eat(input[i]);
        }

        Console.WriteLine(gandalf);
    }
Ejemplo n.º 6
0
    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);
    }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
    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);
    }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
 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;
 }