コード例 #1
0
 //  private string instuction;
 public void handle(string instuction)
 {
     AbstractNode left = null, right = null;
     AbstractNode direction = null, action = null, distance = null;
     Stack<AbstractNode> stack = new Stack<AbstractNode>();
     string[] words = instuction.Split(' ');
     for (int i = 0; i < words.Length; i++)
     {
         if (words[i] == "and")
         {
             left = stack.Pop();
             string word1 = words[++i];
             direction = new DirectionNode(word1);
             string word2 = words[++i];
             action = new ActionNode(word2);
             string word3 = words[++i];
             distance = new DistanceNode(word3);
             right = new SentenceNode(direction, action, distance);
             stack.Push(new AndNode(left, right));
         }
         else
         {
             string word1 = words[i];
             direction = new DirectionNode(word1);
             string word2 = words[++i];
             action = new ActionNode(word2);
             string word3 = words[++i];
             distance = new DistanceNode(word3);
             left = new SentenceNode(direction, action, distance);
             stack.Push(left);
         }
     }
     this.node = stack.Pop();
 }
コード例 #2
0
 public AndNode(AbstractNode left, AbstractNode right)
 {
     this.left = left;
     this.right = right;
 }
コード例 #3
0
 public AndNode(AbstractNode left, AbstractNode right)
 {
     this.left  = left;
     this.right = right;
 }
コード例 #4
0
 public SentenceNode(AbstractNode direction, AbstractNode action, AbstractNode distance)
 {
     this.direction = direction;
     this.action = action;
     this.distance = distance;
 }