public int CompareTo(ClassArray <T> other) { if (this.places.Count > other.places.Count()) { return(-1); } else if (this.places.Count < other.places.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 Ship && other.places[thisKeys[i]] is CruiseLiner) { return(1); } if (this.places[thisKeys[i]] is CruiseLiner && other.places[thisKeys[i]] is Ship) { return(-1); } if (this.places[thisKeys[i]] is Ship && other.places[thisKeys[i]] is Ship) { return((this.places[thisKeys[i]] is Ship).CompareTo(other.places[thisKeys[i]] is Ship)); } if (this.places[thisKeys[i]] is CruiseLiner && other.places[thisKeys[i]] is CruiseLiner) { return((this.places[thisKeys[i]] is CruiseLiner).CompareTo(other.places[thisKeys[i]] is CruiseLiner)); } } } return(0); }
public Prichal(int countStages) { //как добавить эл-ты в список prichalStages = new List <ClassArray <ITransport> >(); ClassArray <ITransport> ship; for (int i = 1; i <= countStages; i++) { ship = new ClassArray <ITransport>(countStages, null); prichalStages.Add(ship); } }
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 MotorShip && other.places[otherKeys[i]] is UltaMegaBuffSuperMotorShip) { return(1); } if (this.places[thisKeys[i]] is UltaMegaBuffSuperMotorShip && other.places[otherKeys[i]] is MotorShip) { return(-1); } if (this.places[thisKeys[i]] is MotorShip && other.places[otherKeys[i]] is MotorShip) { return((this.places[thisKeys[i]] is MotorShip) .CompareTo(other.places[otherKeys[i]] is MotorShip)); } if (this.places[thisKeys[i]] is UltaMegaBuffSuperMotorShip && other.places[otherKeys[i]] is UltaMegaBuffSuperMotorShip) { return((this.places[thisKeys[i]] is UltaMegaBuffSuperMotorShip) .CompareTo(other.places[otherKeys[i]] is UltaMegaBuffSuperMotorShip)); } } } return(0); }