Ejemplo n.º 1
0
        public static void Main()
        {
            var inputLine = Console.ReadLine();

            var mood = MoodFactory.CreateMood(inputLine);

            Console.WriteLine(mood.ToString());
        }
Ejemplo n.º 2
0
 private void SetMood()
 {
     if (this.happinessIndex < -5)
     {
         this.mood = moodFactory.CreateMood("Angry");
     }
     else if (this.happinessIndex < 0)
     {
         this.mood = moodFactory.CreateMood("Sad");
     }
     else if (this.happinessIndex < 15)
     {
         this.mood = moodFactory.CreateMood("Happy");
     }
     else
     {
         this.mood = moodFactory.CreateMood("JavaScript");
     }
 }
Ejemplo n.º 3
0
        public void Run()
        {
            string[] input = Console.ReadLine()
                             .Split();

            int points = 0;

            for (int i = 0; i < input.Length; i++)
            {
                string type = input[i];

                Food currFood = foodFactory
                                .CreateFood(type);

                points += currFood.Happiness;
            }

            Mood mood = new Mood();

            if (points < DefaultPoints)
            {
                mood = moodFactory.CreateMood("angry");
            }
            else if (points >= DefaultPoints &&
                     points < MaxSadPoints)
            {
                mood = moodFactory.CreateMood("sad");
            }
            else if (points >= MinHappyPoints &&
                     points < DefValue)
            {
                mood = moodFactory.CreateMood("happy");
            }
            else if (points >= DefValue)
            {
                mood = moodFactory.CreateMood("javascript");
            }

            Console.WriteLine(points);
            Console.WriteLine(mood.Name);
        }
Ejemplo n.º 4
0
        public void Run()
        {
            int points = 0;

            string[] input = Console.ReadLine()
                             .Split(' ', StringSplitOptions.RemoveEmptyEntries)
                             .ToArray();

            for (int i = 0; i < input.Length; i++)
            {
                string type = input[i];

                Food currentFood = foodFactory.CreateFood(type);
                points += currentFood.Happiness;
            }

            Mood mood = new Mood();

            if (points < -5)
            {
                mood = moodFactory.CreateMood("angry");
            }
            else if (points >= -5 && points <= 0)
            {
                mood = moodFactory.CreateMood("sad");
            }
            else if (points >= 1 && points <= 15)
            {
                mood = moodFactory.CreateMood("happy");
            }
            else if (points > 15)
            {
                mood = moodFactory.CreateMood("javascript");
            }

            Console.WriteLine(points);
            Console.WriteLine(mood.Name);
        }
Ejemplo n.º 5
0
        public void Run()
        {
            int points = 0;

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

            for (int i = 0; i < input.Length; i++)
            {
                string type = input[i];

                Food currentFood = foodFactory.CreateFood(type);
                points += currentFood.Hapiness;
                //foods.Add(currentFood);
            }

            //int points = foods.Sum(x => x.Hapiness);
            Mood mood;

            if (points < -5)
            {
                mood = moodFactory.CreateMood("angry");
            }
            else if (points >= -5 && points < 0)
            {
                mood = moodFactory.CreateMood("sad");
            }
            else if (points >= 1 && points < 15)
            {
                mood = moodFactory.CreateMood("happy");
            }
            else
            {
                mood = moodFactory.CreateMood("javascript");
            }

            Console.WriteLine(points);
            Console.WriteLine(mood.Name);
        }
        public void Run()
        {
            int points = 0;

            string[] tokens = Console.ReadLine()
                              .Split(" ", StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < tokens.Length; i++)
            {
                string foodName = tokens[i];

                Food food = foodFactory.CreateFood(foodName);
                points += food.Happiness;
            }

            Mood mood = new Mood();

            if (points < -5)
            {
                mood = moodFactory.CreateMood("angry");
            }
            else if (points >= -5 && points <= 0)
            {
                mood = moodFactory.CreateMood("sad");
            }
            else if (points >= 1 && points <= 15)
            {
                mood = moodFactory.CreateMood("happy");
            }
            else if (points > 15)
            {
                mood = moodFactory.CreateMood("javascript");
            }

            Console.WriteLine(points);
            Console.WriteLine(mood.Type);
        }
Ejemplo n.º 7
0
        public void Run()
        {
            var input = Console.ReadLine().Split();

            foreach (var type in input)
            {
                Food currentFood = foodFactory.CreateFood(type);
                foods.Add(currentFood);
            }

            int  points = foods.Sum(f => f.Happiness);
            Mood mood;

            if (points < -5)
            {
                mood = moodFactory.CreateMood("angry");
            }

            else if (points >= -5 && points <= 0)
            {
                mood = moodFactory.CreateMood("sad");
            }

            else if (points >= 1 && points <= 15)
            {
                mood = moodFactory.CreateMood("happy");
            }

            else
            {
                mood = moodFactory.CreateMood("javascript");
            }

            Console.WriteLine(points);
            Console.WriteLine(mood.Name);
        }
Ejemplo n.º 8
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.º 9
0
        public void Run()
        {
            foods = new List <Food>();

            string[] data = Console.ReadLine().ToLower().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string name in data)
            {
                Food food = FoodFactory.CreateFood(name);
                foods.Add(food);
            }

            int happiness = CalculateHappiness();

            mood = MoodFactory.CreateMood(happiness);

            Print();
        }
Ejemplo n.º 10
0
    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);
    }
Ejemplo n.º 11
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.º 12
0
    private Mood GetMood()
    {
        var mood = MoodFactory.CreateMood(this.happinessPoints);

        return(mood);
    }