Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            var rude = new Rude();

            var arg = args.Length == 1 ? args[0] : "static";

            switch (arg)
            {
            case "static":
                WriteTitle(SimpleStatic.Title);
                SimpleStatic.AddRulesAndCheck(rude);
                WriteResult(SimpleStatic.Result, rude.GetPath());
                break;

            case "dynamic":
                var example = new DynamicRules(rude, 5);
                WriteTitle(example.Title);
                example.CheckConditions();
                WriteResult(example.Result, rude.GetPath());
                break;

            default:
                return;
            }
        }
Exemplo n.º 2
0
        public DynamicRules(Rude rude, int value)
        {
            _rude  = rude;
            _value = value;
            _rnd   = new Random();

            AddRules();
        }
Exemplo n.º 3
0
        public static void AddRulesAndCheck(Rude rude)
        {
            rude.AddRule(IsAnimal, HasLegs, CreatureFound);
            rude.AddRule(HasLegs, HasTwoLegs, CreatureFound);
            rude.AddRule(HasTwoLegs, CanCountToInfinity, HasHorns);
            rude.AddRule(CanCountToInfinity, CreatureFound, CreatureFound);
            rude.AddRule(HasHorns, HasOneHorn, Poodle);
            rude.AddRule(HasOneHorn, CreatureFound, CreatureFound);
            rude.AddRule(Poodle, null, null);
            rude.AddRule(CreatureFound, null, null);

            rude.CheckConditions(IsAnimal);
        }