Esempio n. 1
0
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }

            FootballClub other = obj as FootballClub;

            if (this.Country.CompareTo(other.Country) > 0)
            {
                return(1);
            }
            else if (this.Country.CompareTo(other.Country) < 0)
            {
                return(-1);
            }
            else
            {
                if (this.City.CompareTo(other.City) > 0)
                {
                    return(1);
                }
                else if (this.City.CompareTo(other.City) < 0)
                {
                    return(-1);
                }
                else
                {
                    if (this.Name.CompareTo(other.Name) == 0)
                    {
                        return(DateTime.Compare(this.Established, other.Established));
                    }
                    else
                    {
                        return(this.Name.CompareTo(other.Name));
                    }
                }
            }
        }
        public static FootballClub[] Extract(String input)
        {
            List<String> clubs=MyParser.GetEntries(input, @"FC\D+\((\D+\d{4})\)");
            FootballClub[] result = new FootballClub[clubs.Count];
            int i = 0;

                foreach (String s in clubs)
                {
                String name;
                String country;
                String city;
                DateTime established;
                String[] parts = s.Split(' ');

                name = parts[1].Substring(0, parts[1].Length);
                city = parts[2].Substring(1, parts[2].Length - 2);
                country = parts[3].Substring(0, parts[3].Length - 1);

                established = DateTime.ParseExact(parts[5].Substring(0, 4), "yyyy", System.Globalization.CultureInfo.InvariantCulture);
                FootballClub res = new FootballClub(name, country, city, established);
                result[i++] = res;
            }
            return result;
        }