Ejemplo n.º 1
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.º 2
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_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.º 4
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.º 5
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.º 6
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));
        }