Пример #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // label1.Text = Program.name;
            this.MaximumSize = this.MinimumSize = this.Size;
            string[] arr  = File.ReadAllLines("ques.txt");
            string[] arr2 = File.ReadAllLines("ans.txt");

            b = new bst();
            for (int i = 0; i < arr.Length; i++)
            {
                QA ab = new QA(arr[i], arr2[i]);
                b.add(ab);
            }
        }
Пример #2
0
        public void add(QA e)
        {
            node n = new node(e);

            if (root == null)
            {
                root = n;
            }
            else
            {
                node temp = root;
                while (true)
                {
                    int x = e.Question1.CompareTo(root.value.Question1);

                    if (x == 1)
                    {
                        if (temp.right != null)
                        {
                            temp = temp.right;
                        }
                        else
                        {
                            temp.right = n;
                            break;
                        }
                    }
                    else
                    {
                        if (temp.left != null)
                        {
                            temp = temp.left;
                        }
                        else
                        {
                            temp.left = n;
                            break;
                        }
                    }
                }
            }
        }
Пример #3
0
 public void Print(ListBox lb, string Question)
 {
     if (lb.Items.Count > 2)
     {
         if (lb.Items[lb.Items.Count - 1].ToString() != "I cannot understand your Question, Please train me." && lb.Items[lb.Items.Count - 2].ToString() != "I cannot understand your Question, Please train me.")
         {
             _Ques = Question;
             string Answer = string.Empty;
             InOrder(root, ref Answer, Question);
             if (string.IsNullOrEmpty(Answer))
             {
                 lb.Items.Add("Mad com : " + "I cannot understand your Question, Please train me.");
             }
             else
             {
                 lb.Items.Add("Mad com : " + Answer);
             }
         }
         else
         {
             QA newInformation = new QA(_Ques, lb.Items[lb.Items.Count - 1].ToString());
             add(newInformation);
             lb.Items.Add("Mad com : " + "Thank you for Training");
         }
     }
     else
     {
         _Ques = Question;
         string Answer = string.Empty;
         InOrder(root, ref Answer, Question);
         if (string.IsNullOrEmpty(Answer))
         {
             lb.Items.Add("Mad com : " + "I cannot understand your Question, Please train me.");
         }
         else
         {
             lb.Items.Add("Mad com : " + Answer);
         }
     }
 }
Пример #4
0
 public node(QA element)
 {
     this.value = element;
     this.right = null;
     this.left  = null;
 }