private static List <EuroDiffusion> parseInputFile(string input) { List <EuroDiffusion> result = new List <EuroDiffusion>(); int numberOfCountry = 0; using (StreamReader sr = new StreamReader(input)) { while (!sr.EndOfStream) { numberOfCountry = Convert.ToInt32(sr.ReadLine()); if (numberOfCountry < 0) { throw new Exception(NUMBER_OF_COUNTRY_SHOULD_BE_POSITIVE); } CoinDistribution[] countries = new CoinDistribution[numberOfCountry]; for (int i = 0; i < numberOfCountry; i++) { string[] splitLine = sr.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); countries[i] = new CoinDistribution(splitLine[0], Convert.ToInt32(splitLine[1]), Convert.ToInt32(splitLine[2]), Convert.ToInt32(splitLine[3]), Convert.ToInt32(splitLine[4])); } EuroDiffusion euroDiffusionSimulation = new EuroDiffusion(countries); result.Add(euroDiffusionSimulation); } } return(result); }
private bool CheckCountryComplete(CoinDistribution country) { for (int x = country.GetXl(); x <= country.GetXh(); x++) { for (int y = country.GetYl(); y <= country.GetYh(); y++) { for (int j = 0; j < numberOfCountries; j++) { if (countries[j].GetCityCoins(x, y) == 0) { return(false); } } } } country.SetComplete(true); return(true); }
public int CompareTo(Object o) { if (o is CoinDistribution) { CoinDistribution country = (CoinDistribution)o; if (numberOfDays > country.numberOfDays) { return(1); } if (numberOfDays < country.numberOfDays) { return(-1); } return(countryName.CompareTo(country.countryName)); } else { return(-1); } }