Example #1
0
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            while (!input.Equals("End"))
            {
                string[] animalInfo = input.Split();
                Animal   animal     = AnimalFactory.GenerateAnimal(animalInfo);

                string[] foodInfo = Console.ReadLine().Split();
                Food     food     = FoodFactory.GenerateFood(foodInfo);

                Console.WriteLine(animal.MakeSound());

                try
                {
                    animal.Eat(food);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                Console.WriteLine(input);

                input = Console.ReadLine();

                Console.ReadLine();
            }
        }
Example #2
0
    public void TakeFood(string[] food)
    {
        foreach (var foo in food)
        {
            Food current = FoodFactory.GenerateFood(foo);
            this.food.Add(current);
        }

        this.CalculateMood();
    }
    public static void Main()
    {
        // Пак сам - да вникна в тази задача!

        string[]    foodArgs = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        List <Food> foods    = new List <Food>();

        foreach (string food in foodArgs)
        {
            Food currentFood = FoodFactory.GenerateFood(food);
            foods.Add(currentFood);
        }

        Mood mood = MoodFactory.GenerateMood(foods);

        Console.WriteLine(foods.Sum(f => f.PointsOfHappines));
        Console.WriteLine(mood);
    }
Example #4
0
        public void Run()
        {
            DrawManager.Draw(Global.SYMBOL, Snake.Body);

            ConsoleWindow.CustomizeConsole();

            while (true)
            {
                Thread.Sleep(50);

                if (Console.KeyAvailable) ChangeDirection();

                DrawManager.Draw(Global.SYMBOL, Snake.Body);

                RemoveFoot();

                Snake.Move();

                if ( this.currentFood.Key == null && this.currentFood.Value == null) this.currentFood = FoodFactory.GenerateFood();

                if (Snake.Head.X == this.currentFood.Value.X && Snake.Head.Y == this.currentFood.Value.Y)
                {
                    Snake.Eat(this.currentFood.Value, this.currentFood.Key);
                    this.currentFood = new KeyValuePair<Food, Coordinate>(null, null);
                }
            }
        }