public void Run() { var run = true; while (run) { DisplayMenu(); switch (_inputOutput.ReadKey().Key) { case ConsoleKey.D1: RunCommand(Command.DisplayNegativeCount); break; case ConsoleKey.D2: RunCommand(Command.FilterNegative); break; case ConsoleKey.D3: RunCommand(Command.DisplayOriginalContent); break; default: run = false; break; } } }
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 void Run() { levelNumbers = arrayGenerator.GenerateArray(gameSettings.DoorsAmount); io.WriteOutput(phraseProvider.GetPhrase("WelcomeStart")); io.WriteOutput($"{gameSettings.ExitCode}"); io.WriteOutput(phraseProvider.GetPhrase("WelcomeEnd")); while (true) { io.WriteOutput(phraseProvider.GetPhrase("Level")); io.WriteOutput($"{currentLevel}"); io.WriteOutput(phraseProvider.GetPhrase("TheDoorsAre")); io.printArray(levelNumbers); do { io.WriteOutput(phraseProvider.GetPhrase("Select")); InputCheck(); if (selectedNum == gameSettings.ExitCode) { break; } } while (!operationWithData.Contains(levelNumbers, selectedNum)); if (selectedNum == gameSettings.ExitCode) { io.WriteOutput(phraseProvider.GetPhrase("Thanks")); break; } else if (selectedNum == gameSettings.ExitDoorNumber) { if (currentLevel > 1) { operationWithData.Divide(levelNumbers, history.Pop()); io.WriteOutput(phraseProvider.GetPhrase("YouSelected")); io.WriteOutput($"{selectedNum}"); io.WriteOutput(phraseProvider.GetPhrase("Previous")); currentLevel--; } else if (currentLevel == 1) { io.WriteOutput(phraseProvider.GetPhrase("AlreadyFirst")); } } else { if (currentLevel < gameSettings.MaxLevel) { operationWithData.Multiply(levelNumbers, selectedNum); history.Push(selectedNum); io.WriteOutput(phraseProvider.GetPhrase("YouSelected")); io.WriteOutput($"{selectedNum}"); io.WriteOutput(phraseProvider.GetPhrase("Next")); currentLevel++; } else { io.WriteOutput(phraseProvider.GetPhrase("MaxLevelReached")); } } } io.ReadKey(); }
private bool ShowInfoMenu() { string userInput; inputOutputModule.ClearMenu(); inputOutputModule.WriteOutput(phraseProvider.GetPhrase(gameSettings.LangPackName, KeysForPhrases.ShowClients)); inputOutputModule.WriteOutput(phraseProvider.GetPhrase(gameSettings.LangPackName, KeysForPhrases.ShowStocksOfClients)); inputOutputModule.WriteOutput(phraseProvider.GetPhrase(gameSettings.LangPackName, KeysForPhrases.ShowStockPrice)); inputOutputModule.WriteOutput(phraseProvider.GetPhrase(gameSettings.LangPackName, KeysForPhrases.ShowHistory)); inputOutputModule.WriteOutput(gameSettings.ExitButton); inputOutputModule.WriteOutput(phraseProvider.GetPhrase(gameSettings.LangPackName, KeysForPhrases.ExitKey)); userInput = inputOutputModule.ReadInput(); if (userInput == "1") { inputOutputModule.ClearMenu(); inputOutputModule.WriteOutput("List of clients\n"); foreach (var client in showDbInfoService.GetAllClients()) { inputOutputModule.WriteOutput($"ID: {client.Id} Name: {client.Name} Surname: {client.Surname} Phone: {client.PhoneNumber} Balance: {showDbInfoService.GetAccountByClientId(client.Id).Balance} Zone: {showDbInfoService.GetAccountByClientId(client.Id).Zone}\n"); } } if (userInput == "2") { int prevID = -1; inputOutputModule.ClearMenu(); inputOutputModule.WriteOutput("List of client's stocks\n"); foreach (var stock in showDbInfoService.GetAllStocksOfClient()) { if (stock.AccountForStock.ClientId != prevID) { inputOutputModule.WriteOutput($"ClientID: {stock.AccountForStock.ClientId}\n"); } inputOutputModule.WriteOutput($"Type: {stock.TypeOfStocks} Quantity: {stock.quantityOfStocks}\n"); prevID = stock.AccountForStock.ClientId; } } if (userInput == "3") { inputOutputModule.ClearMenu(); inputOutputModule.WriteOutput("List of stocks prices\n"); foreach (var stock in showDbInfoService.GetAllStockPrice()) { inputOutputModule.WriteOutput($"Type: {stock.TypeOfStock} Price: {stock.PriceOfStock}\n"); } } if (userInput == "4") { inputOutputModule.ClearMenu(); inputOutputModule.WriteOutput("History of transaction\n"); foreach (var history in showDbInfoService.GetFullHistory()) { inputOutputModule.WriteOutput($"Id: {history.Id} BuyerId: {history.BuyerId} SellerId: {history.SellerId} TypeOfStock: {history.TypeOfStock} QuantityOfStocks: {history.QuantityOfStocks} FullPrice: {history.FullPrice}\n"); } } if (userInput == gameSettings.ExitButton) { return(false); } inputOutputModule.ReadKey(); return(true); }
public void Run() { bool exit = false; string userInput; InputCheckResult checkResult; if (gameSettings == null) { return; } if (TestLangPack() == false) { return; } try { ioModule.WriteOutput(phraseProvider.GetPhrase(KeysForPhrases.Intro, gameSettings.LangPackName)); } catch (ArgumentException ex) { ioModule.WriteOutput(ex.Message); return; } ShowInfo(); while (!CheckWinCondition() && !exit) { string enterThisNum = phraseProvider.GetPhrase(KeysForPhrases.EnterNumber, gameSettings.LangPackName); foreach (int number in doorNumbersHolder) { enterThisNum = enterThisNum + number + " "; } enterThisNum = enterThisNum + Environment.NewLine; ioModule.WriteOutput(enterThisNum); userInput = ioModule.ReadInput(); if (string.IsNullOrEmpty(userInput)) { ioModule.WriteOutput(phraseProvider.GetPhrase(KeysForPhrases.InvalidInput, gameSettings.LangPackName)); continue; } checkResult = CheckIfInputIsValid(userInput); switch (checkResult) { case InputCheckResult.Invalid: { ioModule.WriteOutput(phraseProvider.GetPhrase(KeysForPhrases.InvalidInput, gameSettings.LangPackName)); continue; } case InputCheckResult.Exit: { exit = true; break; } case InputCheckResult.Info: { ShowInfo(); break; } case InputCheckResult.Valid: { NumbersChanger(userInput); break; } } } if (CheckWinCondition()) { ioModule.WriteOutput(phraseProvider.GetPhrase(KeysForPhrases.Win, gameSettings.LangPackName)); } ioModule.WriteOutput(phraseProvider.GetPhrase(KeysForPhrases.Goodbye, gameSettings.LangPackName)); ioModule.WriteOutput(phraseProvider.GetPhrase(KeysForPhrases.CloseProg, gameSettings.LangPackName)); ioModule.ReadKey(); }
private bool ShowInfoMenu() { string userInput; inputOutputModule.ClearMenu(); inputOutputModule.WriteOutput(phraseProvider.GetPhrase(gameSettings.LangPackName, KeysForPhrases.ShowClients)); inputOutputModule.WriteOutput(phraseProvider.GetPhrase(gameSettings.LangPackName, KeysForPhrases.ShowStocksOfClients)); inputOutputModule.WriteOutput(phraseProvider.GetPhrase(gameSettings.LangPackName, KeysForPhrases.ShowBalance)); inputOutputModule.WriteOutput(phraseProvider.GetPhrase(gameSettings.LangPackName, KeysForPhrases.ShowHistory)); inputOutputModule.WriteOutput(gameSettings.ExitButton); inputOutputModule.WriteOutput(phraseProvider.GetPhrase(gameSettings.LangPackName, KeysForPhrases.ExitKey)); userInput = inputOutputModule.ReadInput(); if (userInput == "1") { inputOutputModule.ClearMenu(); inputOutputModule.WriteOutput("List of clients\n"); int lengthOfPage = Convert.ToInt32(AskUser(KeysForPhrases.ShowClientsLength, true)); int numberOfPage = Convert.ToInt32(AskUser(KeysForPhrases.ShowClientsPage, true)); foreach (var client in requestSender.GetPageOfClientsList(lengthOfPage, numberOfPage)) { inputOutputModule.WriteOutput($"ID: {client.Id} Name: {client.Name} Surname: {client.Surname} Phone: {client.PhoneNumber}\n"); } } if (userInput == "2") { int prevID = -1; string filter = AskUser(KeysForPhrases.ShowStocksOfClientsFilter); if (filter == "all") { inputOutputModule.ClearMenu(); inputOutputModule.WriteOutput("List of client's stocks\n"); foreach (var stock in requestSender.GetAllStocksOfClientsList()) { if (stock.ClientId != prevID) { inputOutputModule.WriteOutput($"ClientID: {stock.ClientId}\n"); } inputOutputModule.WriteOutput($"Type: {stock.TypeOfStocks} Quantity: {stock.quantityOfStocks} Price: {stock.PriceOfStock}\n"); prevID = stock.ClientId; } } if (ValidateUserInput(filter, true) == InputCheckResult.Valid) { int clientId = Convert.ToInt32(filter); inputOutputModule.ClearMenu(); if (CheckIfClientIdIsValid(clientId) == InputCheckResult.Invalid) { inputOutputModule.WriteOutput("Invalid Id\n"); inputOutputModule.ReadKey(); return(true); } inputOutputModule.WriteOutput("List of client's stocks\n"); foreach (var stock in requestSender.GetAllStocksOfClientListByClientId(clientId)) { if (stock.ClientId != prevID) { inputOutputModule.WriteOutput($"ClientID: {stock.ClientId}\n"); } inputOutputModule.WriteOutput($"Type: {stock.TypeOfStocks} Quantity: {stock.quantityOfStocks} Price: {stock.PriceOfStock}\n"); prevID = stock.ClientId; } } } if (userInput == "3")//balance { inputOutputModule.ClearMenu(); inputOutputModule.WriteOutput(phraseProvider.GetPhrase(gameSettings.LangPackName, KeysForPhrases.ShowBalance)); int clientId = Convert.ToInt32(AskUser(KeysForPhrases.ShowBalanceId, true)); inputOutputModule.ClearMenu(); if (CheckIfClientIdIsValid(clientId) == InputCheckResult.Invalid) { inputOutputModule.WriteOutput("Invalid Id\n"); inputOutputModule.ReadKey(); return(true); } inputOutputModule.WriteOutput($"Balance of client {clientId}\n"); var account = requestSender.GetAccountByClientId(clientId); inputOutputModule.WriteOutput($"Balance: {account.Balance} Zone: {account.Zone}\n"); } if (userInput == "4") { int clientId = Convert.ToInt32(AskUser(KeysForPhrases.ShowHistoryId, true)); int top = Convert.ToInt32(AskUser(KeysForPhrases.ShowHistoryQuant, true)); inputOutputModule.ClearMenu(); if (CheckIfClientIdIsValid(clientId) == InputCheckResult.Invalid) { inputOutputModule.WriteOutput("Invalid Id\n"); inputOutputModule.ReadKey(); return(true); } inputOutputModule.WriteOutput("History of transaction\n"); foreach (var history in requestSender.GetNClientsHistoryRecords(clientId, top)) { inputOutputModule.WriteOutput($"Id: {history.Id} BuyerId: {history.BuyerId} SellerId: {history.SellerId} TypeOfStock: {history.TypeOfStock} QuantityOfStocks: {history.QuantityOfStocks} FullPrice: {history.FullPrice}\n"); } } if (userInput == gameSettings.ExitButton) { return(false); } inputOutputModule.ReadKey(); return(true); }