Exemplo n.º 1
0
        /// <summary>
        /// Generate animal
        /// </summary>
        /// <param name="animalType"></param>
        /// <returns></returns>
        public Animal.Animal GenerateAnimal(AnimalTypes animalType)
        {
            Animal.Animal an = null;

            switch (animalType)
            {
            case AnimalTypes.Elephant:
                an = new Elephant("a");
                break;

            case AnimalTypes.Rabbit:
                an = new Rabbit("b");
                break;

            case AnimalTypes.Giraff:
                an = new Giraff("c");
                break;

            case AnimalTypes.Wolf:
                an = new Wolf("d");
                break;

            default:
                an = new Elephant("a");
                break;
            }

            return(an);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Generate a fence with an amount of animals
        /// </summary>
        /// <param name="types"></param>
        /// <param name="amount"></param>
        /// <returns></returns>
        public Fence GenerateFence(AnimalTypes types, int amount)
        {
            Animal.Animal[] animals = new Animal.Animal[amount];

            for (int i = 0; i < animals.Length; i++)
            {
                animals[i] = GenerateAnimal(types);
            }

            return(new Fence(animals));
        }
Exemplo n.º 3
0
        /// <summary>
        /// What happens when a animal shits
        /// </summary>
        /// <param name="animal"></param>
        /// <param name="turd"></param>
        private void AnimalShitMethod(Animal.Animal animal, Turd turd)
        {
            Monitor.Enter(TurdBuffer.Lock);
            try
            {
                if (TurdBuffer.IsBufferFull)
                {
                    Monitor.PulseAll(TurdBuffer.Lock);
                }

                TurdBuffer.AddItem(turd);

                if (TurdBuffer.CurrentItems == 1)
                {
                    Monitor.PulseAll(TurdBuffer.Lock);
                }
            }
            finally
            {
                Monitor.Exit(TurdBuffer.Lock);
            }
        }
Exemplo n.º 4
0
 private static void AnimalShat(Animal.Animal animal, turd.Turd turd)
 {
 }