public void Check_If_SplitRule_Generate_Table_Of_Two_Strings()
        {
            string ruleFromDoc   = "1,\"otrzymuje wpis\",[\"ocena z przedmiotów A,B,C  >=3 \",\"zapłacił czesne\"], 1)";
            var    splitedString = OperationsOnString.SplitRuleToTwoPartsConditionsAndAnother(ruleFromDoc);

            Assert.AreEqual(splitedString.Count(), 2);
        }
Ejemplo n.º 2
0
        private Model ExtendedModel(string line)
        {
            line = OperationsOnString.RemoveBeggining(line);
            string[]      tableStrings    = OperationsOnString.SplitRuleToTwoPartsConditionsAndAnother(line);
            List <string> result          = OperationsOnString.SplitArguments(tableStrings[0]);
            List <string> argumentsList   = OperationsOnString.SplitArguments(tableStrings[1]);
            string        sign            = "";
            int           semaphoreNumber = int.Parse(result.Last());
            bool          semaphoreValue  = semaphoreNumber == 1;

            if (result[3].ToLowerInvariant().Contains('>') || result[3].ToLowerInvariant().Contains('<'))  //todo:rozwiązanie działa ale do poprawienia
            {
                if (result[3].Count() < 3)
                {
                    sign = result[3] + "," + result[4];
                }
                else
                {
                    sign = result[3];
                }
            }
            else
            {
                sign = result[3];
            }
            // nie cały znak
            return(new Model(int.Parse(result[0]), result[1], result[2], sign, argumentsList, semaphoreValue));
        }
Ejemplo n.º 3
0
        private Argument ReturnArgument(string line)
        {
            line = OperationsOnString.RemoveBeggining(line);
            List <string> list = OperationsOnString.SplitArguments(line);

            return(new Argument(list[0], list[1]));
        }
Ejemplo n.º 4
0
        private Model PolyModel(string line)
        {
            line = OperationsOnString.RemoveBeggining(line);
            string[]      table1      = OperationsOnString.SplitRuleToTwoPartsConditionsAndAnother(line);
            string[]      table2      = OperationsOnString.SplitRuleToTwoPartsConditionsAndAnother(line);
            List <string> factorsList = OperationsOnString.SplitArguments(table1[1]);
            List <string> result      = OperationsOnString.SplitArguments(table2[0]);

            char[] commaSeparator = new char[] { ',' };


            List <string> powerList  = table2[1].Split(commaSeparator).ToList();
            List <int>    powerList1 = new List <int>();

            foreach (var VARIABLE in powerList)
            {
                powerList1.Add(int.Parse(VARIABLE));
            }

            int  semaphorNumber = int.Parse(result.Last());
            bool semaphorValue  = semaphorNumber == 1;

            return(new Model(int.Parse(result[0]), result[1], result[2], result[3], factorsList, powerList1,
                             semaphorValue));
        }
        public void Check_If_RemoveBeggining_Return_Good_Value_With_Right_Parameter()
        {
            string ruleFromDoc           = "reguła(1,\"otrzymuje wpis\",[\"ocena z przedmiotów A,B,C  >=3 \",\"zapłacił czesne\"], 1)";
            string expectedValue         = "1,\"otrzymuje wpis\",[\"ocena z przedmiotów A,B,C  >=3 \",\"zapłacił czesne\"], 1)";
            var    removeBegginingString = OperationsOnString.RemoveBeggining(ruleFromDoc);

            Assert.AreEqual(expectedValue, removeBegginingString);
        }
Ejemplo n.º 6
0
        private List <string> ListResult(string line, out List <string> listConditions)
        {
            string[] rule = OperationsOnString.SplitRuleToTwoPartsConditionsAndAnother(line);
            rule[0] = OperationsOnString.RemoveBeggining(rule[0]);
            List <string> listResult = OperationsOnString.SplitArguments(rule[0]);

            listConditions = OperationsOnString.SplitArguments(rule[1]);
            return(listResult);
        }
Ejemplo n.º 7
0
        private Fact ModelFact(string line)
        {
            line = OperationsOnString.RemoveBeggining(line);
            List <string> list = OperationsOnString.SplitArguments(line);

            return(new Fact()
            {
                FactName = list[0], FactValue = true
            });
        }
Ejemplo n.º 8
0
        private Constrain RuleChecker(string line)
        {
            line = OperationsOnString.RemoveBeggining(line);
            string[]      table           = OperationsOnString.SplitRuleToTwoPartsConditionsAndAnother(line);
            List <string> table1          = OperationsOnString.SplitArguments(line);
            int           constrainNUmber = int.Parse(table1[0]);
            List <string> conditions      = OperationsOnString.SplitArguments(table[1]);

            return(new Constrain(conditions, constrainNUmber));
        }
Ejemplo n.º 9
0
        private Sound CreateSound(string line)
        {
            var fact          = OperationsOnString.RemoveBeggining(line);
            var factConverted = OperationsOnString.SplitArguments(fact);

            return(new Sound()
            {
                soundNumber = int.Parse(factConverted[0]), soundPath = factConverted[1]
            });
        }
Ejemplo n.º 10
0
        private Advice CreateAdvice(string line)
        {
            var fact          = OperationsOnString.RemoveBeggining(line);
            var factConverted = OperationsOnString.SplitArguments(fact);

            return(new Advice()
            {
                adviceNumber = int.Parse(factConverted[0]), advicePath = factConverted[1]
            });
        }
Ejemplo n.º 11
0
        private Graphic CreateGraphic(string line)
        {
            var fact          = OperationsOnString.RemoveBeggining(line);
            var factConverted = OperationsOnString.SplitArguments(fact);

            return(new Graphic()
            {
                graphicNumber = int.Parse(factConverted[0]), graphicPath = factConverted[1]
            });
        }
Ejemplo n.º 12
0
        public Model SimpleModel(string line)
        {
            line = OperationsOnString.RemoveBeggining(line);
            List <string> result = OperationsOnString.SplitArguments(line);

            int semaphorNumber = int.Parse(result.Last());

            bool semaphorValue = semaphorNumber == 1;

            return(new Model(int.Parse(result[0]), result[1], result[2], result[3],
                             result[4], result[5], semaphorValue));
        }
Ejemplo n.º 13
0
        private Model LinearModel(string line)
        {
            line = OperationsOnString.RemoveBeggining(line);
            string[] table1 = OperationsOnString.SplitRuleToTwoPartsConditionsAndAnother(line);
            string[] table2 = OperationsOnString.SplitRuleToTwoPartsConditionsAndAnother(table1[0]);


            List <string> factorsList   = OperationsOnString.SplitArguments(table1[1]);
            List <string> result        = OperationsOnString.SplitArguments(table2[0]);
            List <string> variablesList = OperationsOnString.SplitArgumentsForModel(table2[1]);

            int  semaphorNumber = int.Parse(result.Last());
            bool semaphorValue  = semaphorNumber == 1;

            return(new Model(int.Parse(result[0]), result[1], result[2], factorsList, variablesList, semaphorValue));
        }
Ejemplo n.º 14
0
        private Fact CreateFact(string line)
        {
            var fact          = OperationsOnString.RemoveBeggining(line);
            var factConverted = OperationsOnString.SplitArguments(fact);

            //if(CheckIfAskable(factConverted)==false)
            return(new Fact()
            {
                FactName = factConverted[0], FactValue = true
            });
            //else
            //{
            //    MessageBox.Show("Fakt " + factConverted + "nie jest dopytywalny");
            //    return null;
            //}
        }
Ejemplo n.º 15
0
        private Argument CreateArgument(string line)
        {
            var argument          = OperationsOnString.RemoveBeggining(line);
            var argumentConverted = OperationsOnString.SplitArguments(argument);

            if (CheckIfAskable(argumentConverted) == false)
            {
                return new Argument()
                       {
                           ArgumentName = argumentConverted[0], Value = argumentConverted[1]
                       }
            }
            ;
            else
            {
                MessageBox.Show("Fakt " + argumentConverted + "nie jest dopytywalny");

                return(null);
            }
        }