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 bool CommonValidateInfo <T, K>(T validator, K value) where T : IValidator <K> { var result = validator.Validate(value); if (result.IsValid) { return(false); } bool retry = false; foreach (var item in result.Errors) { Consol.WriteLineColor(ConsoleColor.Red, item.ErrorMessage); if (item.ErrorCode == Constants.EXIT) { throw new ExitException(); } else if (item.ErrorCode == Models.Constants.ErrorCodes.RETRY) { retry = true; } } return(retry); }
public static void Main(string[] args) { try { do { Console.Clear(); Consol.WriteLineColor(ConsoleColor.Cyan, $"[Paşa Yazıcı]"); Consol.WriteLineColor(ConsoleColor.Cyan, $"[[email protected]]"); Consol.WriteLineColor(ConsoleColor.Cyan, $"[532 654 10 50]\r\n"); Consol.WriteLineColor(ConsoleColor.White, $"______________________________________________________________"); Consol.WriteLineColor(ConsoleColor.Yellow, ConsoleColor.Red, $"Type \"[{Constants.START}]\" to start the rover."); Consol.WriteLineColor(ConsoleColor.Yellow, ConsoleColor.Red, $"Type \"[{Constants.EXIT}]\" to exit the application."); Consol.WriteLineColor(ConsoleColor.White, $"______________________________________________________________\r\n\r\n"); var planetModel = GetParameters(); IRoverCommandService planetService = new RoverCommandService(planetModel); var planetResult = planetService.Run(); Consol.WriteLineColor(ConsoleColor.White, $"\r\n\r\n_______________________RESULT_________________________________\r\n\r\n"); planetResult.ForEach(p => { switch (p.VerboseType) { case ResultType.Warn: Consol.WriteLineColor(ConsoleColor.Yellow, p.Verbose); break; case ResultType.Error: Consol.WriteLineColor(ConsoleColor.Red, p.Verbose); break; case ResultType.Success: Consol.WriteLineColor(ConsoleColor.Green, p.Verbose); break; case ResultType.Info: default: Consol.WriteLineColor(ConsoleColor.White, p.Verbose); break; } }); Consol.WriteLineColor(ConsoleColor.White, $"\r\n\r\n______________________________________________________________\r\n\r\n"); } while (IsRestart()); } catch (ExitException) { } catch (Exception ex) { Consol.WriteLineColor(ConsoleColor.Red, $"Unhandled exception. [Error: {ex.Message}]"); } finally { Consol.WriteLineColor(ConsoleColor.White, $"Press any key to exit"); Console.ReadKey(); } }
static void Main(string[] args) { //User newUser2 = new User(); Console.writeLine("Ingrese nombre de usuario:"); string name = Console.ReadLine(); User newUser = new User(name); // newUser.SetName(name); Console.WriteLine("Ingrese su apellido"); newUser.SetLastName(Console.ReadLine()); Consol.writeLine(newUser.SetFullName()); }
public static void Main(string[] args) { Console.WriteLine("Max:"); string input = Consol.ReadLine(); try { uint max = uint.Parse(input); for (int i = 1; i <= max; i++) { if (i < = 0) { Console.WriteLine(i); continue; } switch (i % 100) { case 11: case 12: case 13: Console.WriteLine($"{i}th"); } switch (i % 10) { case 1: Console.WriteLine("$" { i } st); continue; case 2: Console.WriteLine("$" { i } nd); continue; case 3: Console.WriteLine("$" { i } rd); continue; default: Console.WriteLine("$" { i } th); continue; } } } catch (OverflowException) { Console.WriteLine($"{input} is out of range"); } }
static void Main(string[] args) { bool querSair = false; string[] itensMenuPrincipal = Enum.GetNames(typeof(FormacaoEnum)); string[] intensMenuCategoria = Enum.GetNames(typeof(categorinEnum)); var opcoesFormacao = new List <string> () { " -0 ", " -1 " }; int opcaoFomacaoSelecionada = 0; string menubar = "================="; do { bool formacaoEscolhida = false; do { Console.Clear(); System.Console.WriteLine(menubar); Console.BackgroundColor = ConsoleColor.DarkCyan; Console.ForegroundColor = Console.Black; System.Console.WriteLine("Welcome"); System.Console.WriteLine("Escolha uma formação: "); Consol.ResetColor(); System.Console.WriteLine(menubar); for (int i = 0 i < opcoesFormacao.COunt; i++) { string titulo = TratarTituloMenu(itensMenuPrincipal[i]); if (opcoesFormacao == i) { DestacarOpcao(opcaoFomacao[opcaoFomacaoSelecionada]).Replace("-" ">").Replace(i.ToString); } else { System.Console.WriteLine(opcoesFormacao[i]); } } } } }
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); }
static void Main(string[] args) { Consol.Run(); }
static void Main(string[] args) { Consol.WriteLine("Adrian Gonzalez"); }
void Event_Hander() { Consol.WriteLine("Executed!"); }
public static void Main() { Consol.WriteLine("Hello World."); }