Exemple #1
0
        /**
         * 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]);
                }
            }
        }
Exemple #2
0
 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");
     }
 }
Exemple #3
0
        public main()
        {
            Game = new GameDictionary();
            //fileDictonary = @"D:\TestFolder\wordsEn.txt";
            OpenFileDialog op = new OpenFileDialog();

            op.ShowDialog();
            fileDictonary = op.FileName;
            string[] lines = System.IO.File.ReadAllLines(fileDictonary);
            foreach (string line in lines)
            {
                Game.Add(line, null);
            }
            InitializeComponent();
        }