Beispiel #1
0
        private static CategoryChain Query(CategoryChain categoryChain)
        {
            const string guessMessage = "Is this person {0}?";

            var currentNode = categoryChain.head;

            while (currentNode != null)
            {
                if (MessageBox.Show(String.Format(guessMessage, currentNode.name), "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    return(currentNode.inside);
                }
                currentNode = currentNode.next;
            }


            if (MessageBox.Show(String.Format(guessMessage, categoryChain.complementMember), "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                MessageBox.Show("Great, guessed right one more time!", "Bad Akinator Thing", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(null);
            }

            var newElement = "";

            while (newElement == "")
            {
                newElement = Microsoft.VisualBasic.Interaction.InputBox("Bravo, you have defeated me! Who are you thinking about?", "I give up", "");
            }

            var newCategoryName = "";

            while (newCategoryName == "")
            {
                newCategoryName = Microsoft.VisualBasic.Interaction.InputBox($"{newElement} is _____ but {categoryChain.complementMember} is not.", "Complete", "");
            }

            categoryChain.AddCategory(newCategoryName, newElement);

            return(null);
        }
Beispiel #2
0
 private static void InitializeSampleCategoryChain()
 {
     root = new CategoryChain(complementMember: "D. Pedro I");
     root.AddCategory(categoryName: "a boxer", complementMember: "Muhammad Ali");
 }