Esempio n. 1
0
        public void Add(Mammals mammal)
        {
            if (AnimalsQueue.Count >= 100)
            {
                return;
            }

            Animals animal = (Animals)mammal.BaseAnimals.Clone();

            AnimalsQueue.Enqueue(animal);
            StringQueue.Enqueue(animal.ToString());
            DictionaryAnimals.Add(animal, mammal);
            DictionaryString.Add(animal.ToString(), mammal);

            RefactorObjects();
        }
Esempio n. 2
0
        public void RefactorObjects()
        {
            int i = 0;

            foreach (Animals animal in AnimalsQueue)
            {
                Mammals mammal = (Mammals)DictionaryAnimals[animal].Clone();

                if (i == 0)
                {
                    firstObject = (Mammals)mammal.Clone();
                }
                if (i == AnimalsQueue.Count / 2)
                {
                    middleObject = (Mammals)mammal.Clone();
                }
                if (i == AnimalsQueue.Count - 1)
                {
                    lastObject = (Mammals)mammal.Clone();
                }
                i++;
            }
        }
Esempio n. 3
0
        public override bool Equals(object obj)
        {
            Mammals animal = (Mammals)obj;

            return(Name.Equals(animal.Name) & Kind.Equals(animal.Kind) & Weight == animal.Weight & Size == animal.Size);
        }