static void Main(string[] args)
        {
            var game = new RockPaperScissorsGame();

            bool readyToQuit = false;

            while (!readyToQuit)
            {
                Console.Write("Do you want to play a round? (y/n)");
                var input = Console.ReadLine();

                if (input == "n")
                {
                    readyToQuit = true;
                }
                else
                {
                    game.PlayRound();
                    // that method should play a round and print the result.
                }
            }

            game.PrintSummary();
            // that method should print out a summary of the rounds.
            // (how many wins, how many losses)
        }
        public static void Main()
        {
            Console.WriteLine("Let's play RockPaperScissors.");
            Console.WriteLine("Player 1\'s turn. Please enter either \"Rock\", \"Paper\", or \"Scissors\"");
            string playerOneAnswer      = Console.ReadLine();
            int    playerOneAnswerValue = RockPaperScissorsGame.ConvertPlayerChoiceToNumber(playerOneAnswer);

            while (playerOneAnswerValue == -1)
            {
                Console.WriteLine("That is not a valid choice. Please try again. Enter either \"Rock\", \"Paper\", or \"Scissors\".");
                playerOneAnswer      = Console.ReadLine();
                playerOneAnswerValue = RockPaperScissorsGame.ConvertPlayerChoiceToNumber(playerOneAnswer);
            }
            Console.WriteLine("Player 2\'s turn. Please enter either \"Rock\", \"Paper\", or \"Scissors\"");
            string playerTwoAnswer      = Console.ReadLine();
            int    playerTwoAnswerValue = RockPaperScissorsGame.ConvertPlayerChoiceToNumber(playerTwoAnswer);

            while (playerOneAnswerValue == -1)
            {
                Console.WriteLine("That is not a valid choice. Please try again. Enter either \"Rock\", \"Paper\", or \"Scissors\".");
                playerTwoAnswer      = Console.ReadLine();
                playerTwoAnswerValue = RockPaperScissorsGame.ConvertPlayerChoiceToNumber(playerTwoAnswer);
            }
            int winner = RockPaperScissorsGame.GameResult(playerOneAnswerValue, playerTwoAnswerValue);

            if (winner != 0)
            {
                Console.WriteLine("Player " + winner + " wins!");
            }
            else
            {
                Console.WriteLine("Draw.");
            }
            Console.WriteLine("Press Enter to exit.");
            Console.ReadLine();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            RockPaperScissorsGame game = new RockPaperScissorsGame();

            game.Play();
        }
Exemple #4
0
        static void Main(string[] args)
        {
            RockPaperScissorsGame game = new RockPaperScissorsGame();

            game.Play();
//             string connString = @"Server =.\SQL2k20; Database = SampleDB; Trusted_Connection = True;";

//             int gameId, playerID;
//             string gameCode, gameFirstPlayer, gameSecondPlayer, playerCode, playerDescr;


//             try
//             {
//                 using (SqlConnection conn = new SqlConnection(connString))
//                 {


//                 string query = @"SELECT * FROM [dbo].[fnGetGameInfo](@gameId);";

//                 SqlCommand cmd = new SqlCommand(query, conn);

//                 SqlParameter param1 = new SqlParameter();
//                 param1.ParameterName = "@gameID";
//                 param1.SqlDbType = SqlDbType.Int;
//                 param1.Value = int.Parse(args[0].ToString());
//  //pass parameter to the SQL Command
//                     cmd.Parameters.Add(param1);

//                     //open connection
//                     conn.Open();

//                     //execute the SQLCommand
//                     SqlDataReader dr = cmd.ExecuteReader();

//                     Console.WriteLine(Environment.NewLine + "Retrieving data from database..." + Environment.NewLine);
//                     Console.WriteLine("Retrieved records:");

//                     //check if there are records
//                     if (dr.HasRows)
//                     {
//                         while (dr.Read())
//                         {
//                             gameID = dr.GetInt32(0);
//                             gameCode = dr.GetString(1);
//                             gameFirstPlayer = dr.GetString(2);
//                             gameSecondPlayer = dr.GetString(3);
//                             gameID = dr.GetInt32(4);
//                             gameCode = dr.GetString(5);
//                             gameDescr = dr.GetString(6);

//                             //display retrieved record
//                             Console.WriteLine("{0},{1},{2},{3},{4},{5},{6}", empID.ToString(), empCode, empFirstName, empLastName, locationID, locationCode, locationDescr);
//                         }
//                     }
//                     else
//                     {
//                         Console.WriteLine("No data found.");
//                     }

//                     //close data reader
//                     dr.Close();

//                     //close connection
//                     conn.Close();
//                 }
//             }
//             catch (Exception ex)
//             {
//                 //display error message
//                 Console.WriteLine("Exception: " + ex.Message);
//             }
        }