Пример #1
0
 public override string ToString()
 {
     return(Connective switch
     {
         UnaryPropositionalConnective _ => $"{LeftBracket.GetInstance()}{Connective}{_formulas[0]}{RightBracket.GetInstance()}",
         BinaryPropositionalConnective _ => $"{LeftBracket.GetInstance()}{_formulas[0]}{Connective}{_formulas[1]}{RightBracket.GetInstance()}",
         _ => throw new NotSupportedException("Connective must be unary or binary")
     });
Пример #2
0
        private static void CalcUnaryPropositionalConnective(Stack <object> stack, UnaryPropositionalConnective connective)
        {
            if (stack.Count < 1)
            {
                throw new ArgumentException($"one formula was expected for {connective}");
            }
            try
            {
                var right = (Formula)stack.Pop();

                var newFormula = new PropositionalConnectiveFormula(connective, right);

                stack.Push(newFormula);
            }
            catch (Exception)
            {
                throw new ArgumentException($"one formula was expected for {connective}");
            }
        }