static void Main(string[] args) { //takes our sample file and indexes it into film and actor objects const string f = "smallactors.txt"; List<Film> films = new List<Film>(); List<Actor> actors = new List<Actor>(); using (StreamReader r = new StreamReader(f)) { string line; bool newactor = true; Actor currentActor = new Actor(); Film currentFilm = new Film(); int indx = 0; bool checkID = false; while ((line = r.ReadLine()) != null) { if (line == "") { newactor = true; continue; } if (newactor == true) { currentActor = new Actor(line, new List<Film>()); actors.Add(currentActor); newactor = false; } else { if (checkID == false) { currentFilm = new Film(line, new List<Actor>()); checkID = true; continue; } if (checkID == true) { indx = Convert.ToInt32(line); if (indx >= films.Count) { films.Add(currentFilm); } films[indx].cast.Add(currentActor); currentActor.films.Add(films[indx]); checkID = false; } } } //foreach (Film film in films) //{ // Console.WriteLine(film.name); // foreach (Actor actor in film.cast) // Console.WriteLine(actor.name); // Console.ReadLine(); //} int x = 0; foreach (Actor actor in actors) { Console.WriteLine(x + ".)" + actor.name); x++; //foreach (Film film in actor.films) //Console.WriteLine(film.name); //Console.ReadLine(); } //USER INTERFACE string input1; string input2; Console.WriteLine("Select the first actor by it's corresponding number"); input1 = Console.ReadLine(); Console.WriteLine("Select the second actor by it's corresponding number"); input2 = Console.ReadLine(); string[] words = input1.Split(' '); input1 = words[1]+", "+words[0]; Actor test = actors.Find(item => item.name == input1); if (test == null) { int minDist = 1000; int tempDist = 0; Actor tempActor = new Actor(); Actor bestMatch = new Actor(); for (int i = 0; i < actors.Count; i++) { tempDist = tempActor.DamerauLevenshteinDistance(input1, actors[i].name); if (tempDist < minDist) { minDist = tempDist; bestMatch = actors[i]; } } test = bestMatch; } words = input2.Split(' '); input2 = words[1] + ", " + words[0]; Actor queryActor = new Actor(); queryActor.name = input2; Actor test2 = actors.Find(item => item.name == input2); if (test2 == null) { int minDist = 1000; int tempDist = 0; Actor tempActor = new Actor(); Actor bestMatch = new Actor(); for (int i = 0; i < actors.Count; i++) { tempDist = tempActor.DamerauLevenshteinDistance(input2, actors[i].name); if (tempDist < minDist) { minDist = tempDist; bestMatch = actors[i]; } } test2 = bestMatch; } if (test.DegreeOfSeparation(test2, 1) != -1) { Console.WriteLine("good"); } else Console.WriteLine("bad"); Console.ReadLine(); } }