private List <Policeman> GetClosetPoliceman(double x, double y, IDistanceFindStrategy strategy) { IPolicemanCollection client = new PolicemanCollection(); List <Policeman> policeforce = new List <Policeman>(client.GetAll().ToArray()); return(strategy.GetClosestPolicemen(policeforce, x, y)); }
static void Main() { var client = new PolicemanCollection(); Console.WriteLine("Initial Status"); PrintDb(client); var policemans = new[] { new Policeman("Aane", "A"), new Policeman("Bane", "B"), new Policeman("Cane", "C"), new Policeman("Dane", "D"), new Policeman("Eane", "E"), new Policeman("Fane", "F"), new Policeman("Gane", "G"), new Policeman("Hane", "H"), new Policeman("Iane", "I"), }; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { policemans[i * 3 + j].X = j + 1; policemans[i * 3 + j].Y = i + 1; } } Console.WriteLine("Before Adding"); PrintDb(client); foreach (var policeman in policemans) { policeman.Id = client.Add(policeman); } PrintDb(client); Console.ReadKey(); }