public static void PrintPlaceToConsole(PlaceOfInterest place) { if (place is Museum) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Museum:"); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(place.ToString()); } if (place is Monument) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Monument:"); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(place.ToString()); } }
public static PlaceOfInterestContainer SortCityPlaces(City[] cities) { PlaceOfInterestContainer allPlaces = JoinCitiesPlaces(cities); int minPos = 0; for (int i = 0; i < allPlaces.Count; i++) { minPos = i; for (int j = i + 1; j < allPlaces.Count; j++) { if (allPlaces.GetPlace(j).Year < allPlaces.GetPlace(minPos).Year) { minPos = j; } } if (minPos != i) { PlaceOfInterest temp = allPlaces.GetPlace(i); allPlaces.SetPlace(allPlaces.GetPlace(minPos), i); allPlaces.SetPlace(temp, minPos); } else { for (int j = i + 1; j < allPlaces.Count; j++) { //CompareTo returns -1 if first string is "smaller" if (allPlaces.GetPlace(i).Name.CompareTo(allPlaces.GetPlace(minPos).Name) < 0) { minPos = j; } } if (minPos != i) { PlaceOfInterest temp = allPlaces.GetPlace(i); allPlaces.SetPlace(allPlaces.GetPlace(minPos), i); allPlaces.SetPlace(temp, minPos); } } } return(allPlaces); }
public bool Contains(PlaceOfInterest place) { return(Places.Contains(place)); }
public void SetPlace(PlaceOfInterest place, int index) { Places[index] = place; }
public void AddPlace(PlaceOfInterest place) { Places[Count++] = place; }
public PlaceOfInterestContainer(int max) { Places = new PlaceOfInterest[max]; }