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(); }
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++; } }
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); }