using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MasterProject
{
    public enum EType
    {
        D, JTR, UBW, DBW, LR
    }

    class Node
    {
        public static int[] Values;
        public Node Right;
        public Node Left;
        public EType VAR;
        public string OP;
        public string VAL;

        public Node(string inputVAR, string OP, string VAL)
        {
            this.VAR = GetVal(inputVAR);
            this.OP = OP;
            this.VAL = VAL;
        }

        public EType GetVal(string inputVAR)
        {
            switch (inputVAR.ToUpper())
            {
                case "D":
                    return EType.D;
                case "JTR":
                    return EType.JTR;
                case "UBW":
                    return EType.UBW;
                case "DBW":
                    return EType.DBW;
                case "LR":
                    return EType.LR;
                default:
                    throw new Exception("ERORR");

            }
        }

        public bool IsRight(bool r)
        {
            int intVAL;
            if (int.TryParse(VAL, out intVAL))
            {
                switch (OP)
                {
                    case ">":
                        return Values[(int)VAR] > intVAL;
                    case ">=":
                        return Values[(int)VAR] >= intVAL;
                    case "<":
                        return Values[(int)VAR] < intVAL;
                    case "<=":
                        return Values[(int)VAR] <= intVAL;
                    default:
                        throw new Exception("ERORR");
                }
            }
            else
                return r;
        }
    }
}
