public override void Run() { ModifyTerminalColors(ConsoleColor.Red, ConsoleColor.Black); ConsoleEventing.Msg("Write something"); ModifyTerminalColors(ConsoleColor.Black, ConsoleColor.Red); Console.ReadLine(); Reset(); }
public override void Run() { FirstName = Validator.ValidateString(FirstName, "Please enter your first name"); LastName = Validator.ValidateString(LastName, "Please enter your last name"); Age = Validator.ValidateInt("Please enter your age"); ConsoleEventing.Msg($"First name: {FirstName}\nLast name: {LastName}\nAge: {Age}"); Reset(); }
public void Print() { Double userinput = GetUserInput(); Double sqrt = SquareRoot(userinput); Double elevetedBy2 = SquareBy(userinput, 2); Double elevetedBy10 = SquareBy(userinput, 10); ConsoleEventing.Msg($"Square root: {sqrt}\nEleveted by two: {elevetedBy2}\nElevated by ten: {elevetedBy10}"); }
public void CreateCharacter() { string input = Validator.GetString("Name:"); CharacterType type = SetCharacterType(); CharacterModel character = new CharacterModel(input, type); ConsoleEventing.Success("Character created"); characterCollection.AddCharacter(character); }
public void PrintArr(int[] arr) { string list = ""; foreach (var item in arr) { list += item + " "; } ConsoleEventing.Msg(list); }
public void PrintOdds(int[] arr) { string list = ""; foreach (var item in arr) { if (item % 2 == 0) { list += item + " "; } } ConsoleEventing.Msg(list); }
public static void SetActive(List <T> list) { int idx; if (Welcome) { Welcome = false; idx = Validator.HandleUserMenuChoises(WelcomeMsg); } else { idx = Validator.HandleUserMenuChoises("\nWant to try another one?\n\nOptions\nTasks #1-16\nMenu #99\nExit #404"); } if (idx == 99) { PrintMenu(list); } if (idx == 404) { ConsoleEventing.Msg("Good Bye!"); Thread.Sleep(2); Environment.Exit(0); } foreach (var task in list) { if (idx < 17) { int id = task.GetId(); if (idx == id) { Console.WriteLine(task.GetDescription()); Thread.Sleep(500); task.Run(); Thread.Sleep(500); SetActive(list); } } else if (idx != 99 && idx != 404) { ConsoleEventing.Error("No such task"); SetActive(list); } else { SetActive(list); } } }
public void RunGame() { var random = new Random(); bool FoundIt = false; int CorrectNumber = random.Next(1, 100); int Min = 0; int Max = 100; int Guess = 0; int Guesses = 0; while (!FoundIt) { Guess = Validator.ValidateInt($"Guess a number between {Min} and {Max}"); Guesses++; if (Guesses == 2) { Console.WriteLine($"Hint! The Number you are looking for is {CorrectNumber - 2 } And {CorrectNumber + 2}"); } if (Guess == CorrectNumber) { ConsoleEventing.Success($"You guessed it correctly, champ! Attempts: {Guesses}"); FoundIt = true; return; } else if (Guess >= CorrectNumber) { Max = Math.Min(Max, Guess - 1); ConsoleEventing.Error("Your guess was too high"); FoundIt = false;; } else { Min = Math.Max(Min, Guess + 1); ConsoleEventing.Error("Your guess was too low"); FoundIt = false; } } }
public static string ValidateString(string name, string msg) { bool err = false; while (err || String.IsNullOrEmpty(name)) { string str = Validator.GetString(msg); if (!Validator.CheckString(str)) { ConsoleEventing.Error("Not valid."); err = true; } else { ConsoleEventing.Success("Valid string"); err = false; return(str); } } return(""); }
public void PrintNumbersBetween() { int input1 = Validator.ValidateInt("Please enter a number"); int input2 = Validator.ValidateInt("Please enter another number"); if (input1 == input2 || input1 >= input2) { ConsoleEventing.Error("Try Again! The first number must be smaller than the second."); PrintNumbersBetween(); } else { int[] numbers = Enumerable.Range(input1 + 1, input2 - input1 - 1).ToArray(); string list = ""; foreach (var item in numbers) { list += item + " "; } ConsoleEventing.Msg(list); } }
public static int HandleUserMenuChoises(string msg) { bool err = false; bool isValid = false; while (!err || !isValid) { string str = Validator.GetString(msg); if (!Validator.CheckInt(str)) { ConsoleEventing.Error("Not valid."); err = true; } else { int number = Int32.Parse(str); err = false; return(number); } } return(200); }
public static double ValidateDecimal(string msg) { bool err = false; bool isValid = false; while (!err || !isValid) { string str = Validator.GetString(msg); if (!Validator.CheckDecimal(str)) { ConsoleEventing.Error("Not valid."); err = true; } else { double dec = double.Parse(str); err = false; return(dec); } } return(0); }
public static int ValidateInt(string msg) { bool err = false; bool isValid = false; var number = 0; while (!err || !isValid) { string str = GetString(msg); if (!CheckInt(str)) { ConsoleEventing.Error("Not valid."); err = true; } else { number = Int32.Parse(str); return(number); } } return(number); }
public override void Run() { ConsoleEventing.Msg(TodaysDate); }
private void PrintString(string msg) { ConsoleEventing.Msg(msg); }
public override void Run() { string output = Compare(); ConsoleEventing.Msg(output); }