Ejemplo n.º 1
0
 public Ocean(int countLevels)
 {
     oceanLevels = new List <ClassArray <IAnimal> >();
     for (int i = 0; i < countLevels; i++)
     {
         ocean = new ClassArray <IAnimal>(countPlaces, null);
         oceanLevels.Add(ocean);
     }
 }
 public int CompareTo(ClassArray <T> other)
 {
     if (this.Count() > other.Count())
     {
         return(-1);
     }
     else if (this.Count() < other.Count())
     {
         return(1);
     }
     else
     {
         var thisKeys  = this.places.Keys.ToList();
         var otherKeys = other.places.Keys.ToList();
         for (int i = 0; i < this.places.Count; ++i)
         {
             if (this.places[thisKeys[i]] is Shark && other.places[thisKeys[i]] is TigerShark)
             {
                 return(1);
             }
             if (this.places[thisKeys[i]] is TigerShark && other.places[thisKeys[i]] is Shark)
             {
                 return(-1);
             }
             if (this.places[thisKeys[i]] is Shark && other.places[thisKeys[i]] is Shark)
             {
                 return((this.places[thisKeys[i]] is Shark).CompareTo(other.places[thisKeys[i]] is Shark));
             }
             if (this.places[thisKeys[i]] is TigerShark && other.places[thisKeys[i]] is TigerShark)
             {
                 return((this.places[thisKeys[i]] is TigerShark).CompareTo(other.places[thisKeys[i]] is TigerShark));
             }
         }
     }
     return(0);
 }