示例#1
0
 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());
     }
 }
示例#2
0
        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);
        }
示例#3
0
 public bool Contains(PlaceOfInterest place)
 {
     return(Places.Contains(place));
 }
示例#4
0
 public void SetPlace(PlaceOfInterest place, int index)
 {
     Places[index] = place;
 }
示例#5
0
 public void AddPlace(PlaceOfInterest place)
 {
     Places[Count++] = place;
 }
示例#6
0
 public PlaceOfInterestContainer(int max)
 {
     Places = new PlaceOfInterest[max];
 }