示例#1
0
        public void Navigate(char instruction)
        {
            if (instruction == 'L')
            {
                _robot.Heading--;
            }
            else if (instruction == 'R')
            {
                _robot.Heading++;
            }
            else if (instruction == 'M')
            {
                IMover mover = MoverFactory.Create(_battleArena.Boundary.Locations, _robot.Heading.Value, _robot.Location);

                Location currentLocation = new Location(_robot.Location.X, _robot.Location.Y);
                _robot.Location = mover.Move();

                if (currentLocation == _robot.Location)
                {
                    _robot.Penalties++;
                }
            }
        }
示例#2
0
        public ActionResult GetCode(CodeInstructions procedure)
        {
            BathroomCode input  = new BathroomCode();
            var          reader = new StringReader(procedure.Instructions);
            string       line;
            Keypad       keypad = new Keypad();

            keypad.ButtonsTraversed.Add(5); //start at 5, middle of keypad
            while (null != (line = reader.ReadLine()))
            {
                char[] array = line.ToCharArray();

                // Loop through array.
                for (int i = 0; i < array.Length; i++)
                {
                    // Get character from array.
                    char  letter = array[i];
                    IMove mover  = MoverFactory.GetMover(letter);
                    keypad.Move(mover);
                }
                input.Code.Add(keypad.ButtonsTraversed.Last());
            }
            return(PartialView("Code", input));
        }
示例#3
0
        public void Navigate()
        {
            IMover mover = MoverFactory.Create(_mower);

            mover.Move();
        }