public ActionResult GetWeirdoCode(CodeInstructions procedure) { WeirdoBathroomCode input = new WeirdoBathroomCode(); var reader = new StringReader(procedure.Instructions); string line; WeirdoKeypad keypad = new WeirdoKeypad(); keypad.ButtonsTraversed.Add('5'); //still start at 5 while (null != (line = reader.ReadLine())) { char[] array = line.ToCharArray(); for (int i = 0; i < array.Length; i++) { char letter = array[i]; IMoveWeird mover = WeirdMoverFactory.GetMover(letter); keypad.Move(mover); } input.Code.Add(keypad.ButtonsTraversed.Last()); } return(PartialView("WeirdoCode", input)); }
public void Move(IMoveWeird imover) { imover.Move(this, ButtonsTraversed.Last()); }