private static bool IsRestart() { Consol.WriteColor(ConsoleColor.Yellow, ConsoleColor.Red, ConsoleApp.Properties.Resources.TryAgain); return((new List <char> { 'Y', 'y' }).Contains(Console.ReadKey().KeyChar)); }
private static IPointModel GetUpperRightInput() { UpperRightPointModel upperRightPointModel = new UpperRightPointModel(); UpperRightInputValidator validator = new UpperRightInputValidator(); string upperRightCoordinateInput; do { Consol.WriteColor(ConsoleColor.Red, ConsoleApp.Properties.Resources.UpperRightInputLabel); upperRightCoordinateInput = Console.ReadLine().Trim(); } while (CommonValidateInfo(validator, upperRightCoordinateInput)); string[] values = upperRightCoordinateInput.Trim().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); upperRightPointModel.X = Convert.ToInt32(values[0]); upperRightPointModel.Y = Convert.ToInt32(values[1]); return(upperRightPointModel); }
private static MoveListModel GetMoveListInput() { MoveListModel moveListModel = new MoveListModel(); MoveListInputValidator validator = new MoveListInputValidator(); string moveListInput; do { Consol.WriteColor(ConsoleColor.Red, ConsoleApp.Properties.Resources.MoveListInputLabel); moveListInput = Console.ReadLine().Trim(); } while (CommonValidateInfo(validator, moveListInput)); var values = moveListInput.ToCharArray().ToList(); values.ForEach(p => moveListModel.Add(Enum.Parse <MoveType>(p.ToString().ToUpperInvariant()))); return(moveListModel); }
private static List <IRoverCommandItemModel> GetRoverCommandInput(IPointModel upperRight) { List <IRoverCommandItemModel> roverCommandList = new List <IRoverCommandItemModel>(); do { var rover = GetRoverInput(upperRight); var moveList = GetMoveListInput(); roverCommandList.Add(new RoverCommandItemModel { MoveListModel = moveList, RoverModel = rover }); Consol.WriteColor(ConsoleColor.Yellow, ConsoleColor.Red, ConsoleApp.Properties.Resources.AddNewLabel); } while ((new List <char> { 'Y', 'y' }).Contains((char)Console.ReadLine().Trim().First())); return(roverCommandList); }
private static RectangleRoverModel GetRoverInput(IPointModel upperRight) { RectangleRoverModel rectangleRoverModel = new RectangleRoverModel(); RectangleRoverInputValidator validator = new RectangleRoverInputValidator(); RoverMapValidator roverMapValidator = new RoverMapValidator(upperRight); string rectangleRoverInput; do { do { Consol.WriteColor(ConsoleColor.Red, ConsoleApp.Properties.Resources.RoverInputLabel); rectangleRoverInput = Console.ReadLine().Trim(); } while (CommonValidateInfo(validator, rectangleRoverInput)); string[] values = rectangleRoverInput.Trim().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); rectangleRoverModel.X = Convert.ToInt32(values[0]); rectangleRoverModel.Y = Convert.ToInt32(values[1]); rectangleRoverModel.Direction = Enum.Parse <DirectionType>(values[2].ToUpperInvariant()); } while (CommonValidateInfo(roverMapValidator, rectangleRoverModel)); return(rectangleRoverModel); }