コード例 #1
0
ファイル: Interpretator.cs プロジェクト: Vorontsova1347/Trees
 public void GetValue()
 {
     if (Operation == ' ')
     {
         return;
     }
     if (Operation == '+')
     {
         Left.GetValue();
         Right.GetValue();
         Value = Left.Value + Right.Value;
     }
     if (Operation == '-')
     {
         Left.GetValue();
         Right.GetValue();
         Value = Right.Value - Left.Value;
     }
 }
コード例 #2
0
ファイル: Interpretator.cs プロジェクト: Vorontsova1347/Trees
 public int Inter(string s)
 {
     PointError = new List <int>();
     Root       = null;
     FormTree(s);
     Root.GetValue();
     if (PointError.Count != 0)
     {
         throw new InputError();
     }
     return(Root.Value);
 }