Ejemplo n.º 1
0
        private void updateTree()
        {
            Console.Write("You win! What were you thinking of?");
            string userObject = Console.ReadLine();

            Console.Write("Please enter a question to distinguish a(n) "
                          + this.message + " from " + userObject + ": ");
            string userQuestion = Console.ReadLine();

            Console.Write("If you were thinking of a(n) " + userObject
                          + ", what would the answer to that question be?");
            char input = getYesOrNo(); //y or n

            if (input == 'y')
            {
                this.noNode  = new BtNode(this.message);
                this.yesNode = new BtNode(userObject);
            }
            else
            {
                this.yesNode = new BtNode(this.message);
                this.noNode  = new BtNode(userObject);
            }
            Console.Write("Thank you my knowledge has been increased");
            this.setMessage(userQuestion);
        }
Ejemplo n.º 2
0
 public BtTree(string question, string yesGuess, string noGuess)
 {
     rootNode = new BtNode(question);
     rootNode.setYesNode(new BtNode(yesGuess));
     rootNode.setNoNode(new BtNode(noGuess));
 }
Ejemplo n.º 3
0
 public void setYesNode(BtNode node)
 {
     yesNode = node;
 }
Ejemplo n.º 4
0
 /**
  * Constructor for the nodes: This class holds an String representing
  * an object if the noNode and yesNode are null and a question if the
  * yesNode and noNode point to a BTNode.
  */
 public BtNode(string nodeMessage)
 {
     message = nodeMessage;
     noNode  = null;
     yesNode = null;
 }
Ejemplo n.º 5
0
 public void setNoNode(BtNode node)
 {
     noNode = node;
 }