Exemple #1
0
    public int Match(DishSummary dishSummary)
    {
        int weight = 0;

        foreach (KeyValuePair <String, ICondition> kvp in propertyConditionDictionary)
        {
            String     propertyName = kvp.Key;
            ICondition condition    = kvp.Value;

            IDishProperty dishProperty = dishSummary.GetDishProperty(propertyName);

            bool propertyNotFound = (dishProperty == null);

            if (propertyNotFound)
            {
                return(0);
            }

            bool valueMatched = condition.IsTrue(dishProperty.value);

            if (valueMatched)
            {
                weight += (dishProperty.value > 0) ? dishProperty.value : 1;
            }
            else
            {
                return(0);
            }
        }

        return(weight);
    }
Exemple #2
0
 void Start()
 {
     dishSummary = new DishSummary(cookbook);
 }