예제 #1
0
        private int Applicable(Regle r)
        {
            int iNiveauMax = -1;

            foreach (IFait f in r.Hypot)
            {
                IFait fTrouve = _bdFaits.Chercher(f.Libelle());
                if (fTrouve == null)
                {
                    if (f.Question() != null)
                    {
                        fTrouve = CalculFait.Determiner(f, this);
                        _bdFaits.Ajouter(fTrouve);
                        iNiveauMax = Math.Max(iNiveauMax, 0);
                    }
                    else
                    {
                        return(-1);
                    }
                }
                if (!fTrouve.Valeur().Equals(f.Valeur()))
                {
                    return(-1);
                }
                else
                {
                    iNiveauMax = Math.Max(iNiveauMax, fTrouve.Niveau());
                }
            }
            return(iNiveauMax);
        }
예제 #2
0
 public void AjouterRegle(string sRegle)
 {
     string[] aTmp = sRegle.Split(new[] { " : " }, StringSplitOptions.RemoveEmptyEntries);
     if (aTmp.Length == 2)
     {
         string[] aHypotThese = aTmp[1].Split(new[] { "SI", " ALORS " }, StringSplitOptions.RemoveEmptyEntries);
         if (aHypotThese.Length == 2)
         {
             List <IFait> lHypot = new List <IFait>();
             string[]     aHypot = aHypotThese[0].Split(new[] { " ET " }, StringSplitOptions.RemoveEmptyEntries);
             foreach (string sHypot in aHypot)
             {
                 lHypot.Add(CalculFait.Determiner(sHypot));
             }
             IFait these = CalculFait.Determiner(aHypotThese[1].Trim());
             _bdRegles.Ajouter(new Regle(aTmp[0], lHypot, these));
         }
     }
 }