/** * The recursive method takes in three parameters, **/ private void recurseWords(Word wordSoFar, Board bBoard, BoardLocation loc) { String str = wordSoFar.toString(); bBoard.markAsTaken(loc); BoardLocation[] adjLoc = bBoard.getAdjacentUntakens(loc); if (wordSoFar.getLength() > 2 && Game.ContainsKey(str)) { if (!boogles.ContainsKey(str)) { boogles.Add(str, null); } validPaths++; } if (!this.wordsExistThaGameartWith(str)) { return; } else { for (int i = 0; i < adjLoc.Length; i++) { Word newWord = wordSoFar.makeCopy(); newWord.addLetter(bBoard.letterAtLocation(adjLoc[i])); recurseWords(newWord, bBoard.makeCopy(), adjLoc[i]); } } }
private void button2_Click(object sender, EventArgs e) { if (boogles.ContainsKey(textBox2.Text) == true) { if (rs.ContainsKey(textBox2.Text) == false) { rs.Add(textBox2.Text, null); point++; label2.Text = point.ToString(); if (rs.Count == boogles.Count) { MessageBox.Show("You win! Point = " + point); rs.Clear(); } } else { MessageBox.Show("You have found this word already!"); } } else { MessageBox.Show("This word doesn't exist"); } }