public MazeObject(IInteractionType i)
 {
     _surroundings = new Surroundings();
     _discovered = false;
     _interaction = i;
     _position = new Position(0, 0);
 }
        public static IInteractionType CreateInteractionTypeSpecialised(InteractionTypeEnum interactionType)
        {
            IInteractionType rc = null;

            switch (interactionType)
            {
            case InteractionTypeEnum.ConsoleUser:
                rc = new UserConsoleInteraction();
                break;

            default:
                rc = new BaseInteraction();
                break;
            }

            return(rc);
        }
示例#3
0
        public static void Main(string[] args)
        {
            IInteractionType interactionType = InteractionFactory.CreateInteractionTypeSpecialised(InteractionTypeEnum.ConsoleUser);

            long primesRequested = interactionType.GetValue();

            if (primesRequested > 0)
            {
                var pns = new PrimeNumberService(primesRequested);

                var timeTaken = new Stopwatch();
                timeTaken.Start();
                var primes = pns.FindPrimeNumbers(2);
                timeTaken.Stop();
                var msg = $"Time taken to calc {primesRequested} was {timeTaken.ElapsedMilliseconds} (milliseconds); per prime avg {timeTaken.ElapsedMilliseconds / primesRequested} (milliseconds)";
                interactionType.PrintValue(primes);
                interactionType.PrintValue(msg);
            }
        }
 protected void SetInteraction(IInteractionType i)
 {
     _interaction = i;
 }