private void Button_Click(object sender, RoutedEventArgs e) { String userInp; int[] userInt = new int [3]; userInp = Question_Box.Text; String[] temp = userInp.Split(' '); userInt[0] = int.Parse(temp[0]); userInt[1] = int.Parse(temp[1]); userInt[2] = int.Parse(temp[2]); HideAndSeek.letsPlayInput(userInt); foreach (Grid gr in mainCanvas.Children.OfType <Grid>()) { foreach (Ellipse el in gr.Children.OfType <Ellipse>()) { colorBack(el); } } if (HideAndSeek.getIsFound()) { float awaitTime = 0; awaitTime = (HideAndSeek.getListVisited().Count + 1) * 1000; drawDFS(HideAndSeek.getListVisited()); drawSolution(HideAndSeek.getListSolution(), awaitTime); Answer_Box.Text = "Found"; } else { Answer_Box.Text = "Not Found"; } }
public Page3() { HnS HideAndSeek = new HnS(); int houseCount = HideAndSeek.getGraphHnS().getHouseCount(); int[,] matrixOfEllipse = new int[houseCount + 1, 3]; float awaitTime = 0; InitializeComponent(); drawMap(HideAndSeek, matrixOfEllipse); //List<int> temporary = new List<int>(){ 1, 2, 3 }; //drawDFS(temporary); using (TextReader new_reader = File.OpenText("question.txt")) { int sumQuestion = int.Parse(new_reader.ReadLine()); for (int i = 0; i < sumQuestion; i++) { string temp = new_reader.ReadLine(); string[] temp2 = temp.Split(' '); int userChoice = int.Parse(temp2[0]); int hideHouse = int.Parse(temp2[1]); int startHouse = int.Parse(temp2[2]); List <int> listVisited = new List <int>(); List <int> listfix = new List <int>(); listfix.Add(hideHouse); List <int>[] list_prec = new List <int> [HideAndSeek.getCountHouse() + 1]; for (int j = 0; j <= HideAndSeek.getCountHouse(); j++) { list_prec[j] = new List <int>(); } HideAndSeek.solve(HideAndSeek.getGraphHnS(), startHouse, hideHouse, listVisited, userChoice, list_prec); if (HideAndSeek.getIsFound()) { HideAndSeek.makeSolution(hideHouse, list_prec, listfix); listfix.Sort(); drawDFS(listVisited); awaitTime = (listVisited.Count + 1) * 1000; drawSolution(listfix, awaitTime); } else { Console.WriteLine("No"); } } } }