예제 #1
0
 public Relation(Relation r,Element e1,int x,int y)
 {
     this.e1 = e1;
     this.r1 = r;
     this.coordinate.X = x;
     this.coordinate.Y = y;
 }
예제 #2
0
 public void SetRelationParametrs(int number, Relation r)
 {
     ms.SetRelationParametrs(number, r);
 }
예제 #3
0
 public void AddRelation(Relation r)
 {
     ms.AddRelation(r);
 }
예제 #4
0
 public void AddRelation(Relation r)
 {
     relations.Add(r); // клонировать?
 }
예제 #5
0
        public string getOut(Element[] input)
        {
            this.input = input;
            List <Element> agentsLayerOut = new List <Element>();

            for (int i = 0; i < input.Length; i++)
            {
                for (int j = 0; j < agents.Count; j++)
                {
                    if (agents[j].getOut(input[i]))
                    {
                        agentsLayerOut.Add(agents[j].getSpecializationElement());
                        break;
                    }
                }
            }

            if (agentsLayerOut.Count != input.Length)
            {
                return(CheckResult(input));
            }

            Relation relation_buffer  = null;
            int      elements_counter = 0;
            char     result           = '-';
            int      k = 0;

            // вообще не уверен в этом алгоритме
            while (result == '-' && k < relations.Count)
            {
                if (relation_buffer == null)
                {
                    try
                    {
                        if (relations[k].checkElement(agentsLayerOut[elements_counter], agentsLayerOut[elements_counter + 1]))
                        {
                            relation_buffer   = relations[k]; // клонировать?
                            elements_counter += 2;
                            if ((result = relations[k].checkChar()) == '-')
                            {
                                k = 0;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        if (relations[k].checkElement(agentsLayerOut[elements_counter], null))
                        {
                            relation_buffer   = relations[k]; // клонировать?
                            elements_counter += 2;
                            if ((result = relations[k].checkChar()) == '-')
                            {
                                k = 0;
                            }
                        }
                    }
                }
                else
                {
                    if (relations[k].checkRelation(relation_buffer, agentsLayerOut[elements_counter]))
                    {
                        relation_buffer = relations[k]; // клонировать?
                        elements_counter++;
                        if ((result = relations[k].checkChar()) == '-')
                        {
                            k = 0;
                        }
                    }
                }
                k++;
            }
            return(result.ToString());
        }
예제 #6
0
 public void SetRelationParametrs(int number, Relation r)
 {
     relations[number].Specialization_Char = r.Specialization_Char;
     relations[number].setFinal(r.isFinal());
 }
예제 #7
0
 public bool checkRelation(Relation r, Element e)
 {
     if (this.r1 == null || this.e1 == null) return false;
     if (this.r1.Equals(r))
         if (this.e1.Equals(e))
         {
             end_flag = true;
             return true;
         }
     return false;
 }
예제 #8
0
 public void AddRelation(Relation r)
 {
     relations.Add(r); // клонировать?
 }
예제 #9
0
        private char FindRelations(Relation rel, List<Element> el)
        {
            char result = '-';

            List<Relation> possibleRelations = new List<Relation>();

            for (int j = 0; j < el.Count; j++)
            {
                for (int k = 0; k < relations.Count; k++)
                {
                    if (relations[k].itRel())
                    {
                        if (relations[k].checkRelation(rel, el[j]))
                        {
                            if ((result = relations[k].checkChar()) == '-')
                                result = FindRelations(relations[k], el);
                        }
                    }
                }

            }
            return result;
        }
예제 #10
0
 public void SetRelationParametrs(int number, Relation r)
 {
     relations[number].Specialization_Char = r.Specialization_Char;
     relations[number].setFinal(r.isFinal());
 }