static void Main(string[] args) { /*** * Whatever you do, do NOT type this in: * O'Malley * '; Delete Player where Number = 22; -- * '; Update Player Set Name = 'Mike Morel' where Number = 12; -- * '; Drop table Player; -- * ***/ string cs = "Server=.\\SQLEXPRESS;Database=RosterDB;Trusted_Connection=True;"; IPlayerDAO dao = new PlayerSqlDAO(cs); while (true) { Console.Clear(); Console.WriteLine("Welcome to Employee Search"); Console.Write("Please enter a name to search for (QQ to Quit):"); string searchString = Console.ReadLine(); if (searchString.ToLower() == "qq") { break; } IList <Player> players = dao.SearchPlayer(searchString); foreach (Player player in players) { Console.WriteLine(player.ToString()); } Console.Write($"{players.Count} players found. Press Any Key to continue"); Console.ReadKey(); } //select* from employee where last_name like '%son' OR 1 = 1-- % ' //select* from employee where last_name like '%son' OR 1 = 1; select @@VERSION-- % ' //Console.ReadKey(); }
static void Main(string[] args) { //Create database connection to pull in players saved to db // IPlayerDAO playerDAO = new PlayerSqlDAO(@"Server=.\SQLEXPRESS;Database=HangmanPlayers;Trusted_Connection=True;"); // DEV-TSMITH, ONOSYSHQ\tsmith // Data Source=(local);Initial Catalog=Marys;Trusted_Connection=yes" IPlayerDAO playerDAO = new PlayerSqlDAO(@"Data Source=(local);Initial Catalog=HangmanPlayers;Trusted_Connection=yes"); //Create new menu object for entering players menu PlayersCLI cli = new PlayersCLI(playerDAO); //Run the 1st CLI to get the player cli.RunCLI(); //Console.ForegroundColor = ConsoleColor.DarkBlue; Console.WriteLine("Welcome to Hangman!\n"); Console.Write("Would you like to play a round? (y/n) "); string playGame = Console.ReadLine(); int numberOfRoundsPlayed = 0; while (playGame.ToLower().Equals("y")) { //Create a new game board object and track rounds played. Hangman gameBoard = new Hangman(++numberOfRoundsPlayed); //Print initial gameboard to screen gameBoard.PrintOutBoard(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(); //Console.WriteLine($"Word to guess: {gameBoard.pickedWord}"); //While number of tries isn't up or guess isn't there while (gameBoard.RemainingAttempts > 0) { Console.ForegroundColor = ConsoleColor.DarkYellow; Console.Write("Guess a letter: "); Console.ResetColor(); string letterGuessed = Console.ReadLine(); //Check if character is in the picked word //pass in string with guessed character gameBoard.ContainsLetter(letterGuessed); if (gameBoard.GuessedCharacters.Equals(gameBoard.PickedWord)) { Console.WriteLine($"guessed word: {gameBoard.GuessedCharacters.ToString()}"); gameBoard.PrintOutBoard(); break; } } Console.ForegroundColor = ConsoleColor.White; Console.Write("\nWould you like to play again? (y/n) "); playGame = Console.ReadLine(); //Increment RoundCounter gameBoard.PlayAnotherRound(); } Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("Thank you for playing.\n"); Console.ResetColor(); }