//Comparing method public override bool Compare(LankytinaVieta place) { if (place is Muziejus) { Muziejus a = this as Muziejus; Muziejus b = place as Muziejus; return(a.Price >= b.Price); } return(false); }
/// <summary> /// Sorts places /// </summary> public void SortPlaces() { for (int i = 0; i < Count - 1; i++) { int m = i; for (int j = i + 1; j < Count; j++) { if (Places[i].Compare(Places[j])) { m = j; LankytinaVieta a = Places[i]; Places[i] = Places[m]; Places[m] = a; } } } }
/// <summary> /// Adds place /// </summary> /// <param name="place">object</param> public void AddPlace(LankytinaVieta place) { Places[Count] = place; Count++; }
abstract public bool Compare(LankytinaVieta place); //For comparing