public void ShowIntro() { _inputOutput.WriteLine("**************************************"); _inputOutput.WriteLine("* Welcome to 2 Card Poker Challenge! *"); _inputOutput.WriteLine("**************************************"); _inputOutput.WriteLine(); }
private void DisplayMenu() { _inputOutput.Clear(); _inputOutput.WriteLine("Select mode:"); _inputOutput.WriteLine("1) Display negative words count"); _inputOutput.WriteLine("2) Filter negative words"); _inputOutput.WriteLine("3) Display original text"); _inputOutput.WriteLine("Any other - exit"); }
public void Play(string password = null) { password = password ?? CreateRandomPassword(); var correctPositions = 0; while (correctPositions != 4) { correctPositions = GuessPasswordAndCheck(password); } _inout.WriteLine("Congratulations you guessed the password in " + _tries + " tries."); }
private static void PrintSalute(IInputOutput inputOutput) { var assembly = Assembly.GetExecutingAssembly(); var assemblyName = assembly.GetName(); inputOutput.WriteLine("{0} {1}", assemblyName.Name, assemblyName.Version); }
private ContentProcessorResult DisplayResult(string content, ContentProcessorResult result, Command command) { if (command.Equals(Command.DisplayNegativeCount)) { _inputOutput.WriteLine("Scanned the text:"); } _inputOutput.WriteLine(content); if (command.Equals(Command.DisplayNegativeCount) || command.Equals(Command.DisplayOriginalContent)) { _inputOutput.WriteLine("Total Number of negative words: " + result.NegativeWordsCount); } _inputOutput.WriteLine("Press ANY key to exit."); _inputOutput.ReadKey(); return(result); }
public static void RunFactorial(IInputOutput io, IMathOperations math) { io.WriteLine("Michael Wright"); io.WriteLine("CS 2450\n"); io.Write("Enter a number to get a factorial: "); int factorialNumber = 0; bool parseSucceeded = int.TryParse(io.ReadLine(), out factorialNumber); if (!parseSucceeded) { return; } int sum = math.Factorial(factorialNumber); io.WriteLine("Factorial Value is {0}", sum); io.ReadLine(); }
private void PrintSalute(IInputOutput inputOutput) { //var assembly = Assembly.GetExecutingAssembly(); //var assemblyName = assembly.GetName(); //inputOutput.WriteLine("{0} {1}", assemblyName.Name, assemblyName.Version); var appVer = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); var bootVer = Resources.GetString(Resources.StringResources.BOOTLOADER_VER); inputOutput.WriteLine($" GHI Electronics, LLC{Strings.NewLine}----------------------{Strings.NewLine} Boot Loader {bootVer} App Ver.{appVer}{Strings.NewLine}"); }
private Either <IValidResult, IInvalidResult> Run() { const char DELIMITER = ','; _io.WriteLine(Settings.Default.ConfigurationQuestion); var stallConfig = _io.ReadLine(); if (string.IsNullOrWhiteSpace(stallConfig)) { return(new EmptyInputResult()); } var tokens = stallConfig.Trim(DELIMITER).Split(DELIMITER); var stalls = Array.ConvertAll(tokens, int.Parse); if (stalls.Any(s => !VALID_STALL_ENTRIES.Contains(s))) { return(new InvalidInputResult()); } return(new ValidInputResult(stalls)); }
public IApplicationState PlayAgain() { _io.WriteLine(Settings.Default.PlayAgainQuestion); var result = PlayAgain(_io.ReadLine()); _io.Clear(); if (result) { return(new ApplicationStatePlay(_dockingSystem, _io, _printOptions)); } return(new ApplicationStateStop()); }
public void Run() { while (true) { if (_cancellation.IsCancellationRequested) { break; } try { string[] inputs = _inputOutput.ReadLine().Split(' '); int myScore = int.Parse(inputs[0]); int opponentScore = int.Parse(inputs[1]); int visiblePacCount = int.Parse(_inputOutput.ReadLine()); // all your pacs and enemy pacs in sight List <PacKey> seenKeys = new List <PacKey>(); for (int i = 0; i < visiblePacCount; i++) { var line = _inputOutput.ReadLine(); Console.Error.WriteLine($"Pac line {line}"); inputs = line.Split(' '); int pacId = int.Parse(inputs[0]); // pac number (unique within a team) bool mine = inputs[1] != "0"; // true if this pac is yours short x = short.Parse(inputs[2]); // position in the grid short y = short.Parse(inputs[3]); // position in the grid string typeId = inputs[4]; // unused in wood leagues short speedTurnsLeft = short.Parse(inputs[5]); // unused in wood leagues short abilityCooldown = short.Parse(inputs[6]); // unused in wood leagues var location = new Location(x, y); Pac pac; var key = new PacKey(pacId, mine); seenKeys.Add(key); if (!_pacs.ContainsKey(key)) { _pacs.Add(key, new Pac(pacId, mine, _actionStrategy, new GiveWayMovementStrategy(_gameGrid))); } pac = _pacs[key]; pac.AddLocation(location); pac.AbilityCooldown = abilityCooldown; pac.SpeedTurnsLeft = speedTurnsLeft; pac.Type = typeId; //_gameGrid.VisiblePelletsFrom(pac.Location); } var deletion = _pacs.Select(p => p.Key).Where(p => !seenKeys.Contains(p)); foreach (var d in deletion) { _pacs.Remove(d); } int visiblePelletCount = int.Parse(_inputOutput.ReadLine()); // all pellets in sight _gameGrid.SetPellets(ParsePellets(visiblePelletCount)); _gameGrid.SetEnemies(_pacs.Values.Where(p => !p.Mine)); _gameGrid.SetMyPacs(_pacs.Values.Where(p => p.Mine && p.Type != PacType.Dead)); //Console.Error.WriteLine(_gameGrid.ToString()); // Write an action using Console.WriteLine() // To debug: Console.Error.WriteLine("Debug messages..."); //_inputOutput.WriteLine("MOVE 0 15 10"); // MOVE <pacId> <x> <y> var myPacs = _pacs.Values.Where(p => p.Mine); var nextActions = myPacs.Select(pac => pac.NextAction(_gameGrid, _cancellation)).ToDictionary(p => p.Pac.Key); var collisions = nextActions.Values.Where(n => n is MoveAction).GroupBy(g => ((MoveAction)g).Location).Where(g => g.Count() > 1); foreach (var collision in collisions) { var giveWayer = collision.First().Pac; nextActions[giveWayer.Key] = giveWayer.GiveWay(_cancellation); } var moves = string.Join("|", nextActions.Values); _inputOutput.WriteLine(moves); } catch (OperationCanceledException) { break; } } }
public void WriteNullString() { Assert.That(() => _ioStrings.WriteLine(null), Throws.ArgumentNullException); }