WSE

WSE
using System;

int firstPlayerScore = 0;
int secondPlayerScore = 0;
//int winningScore = 3;

Console.WriteLine("How many wins to win?");
//int winningScore = int.Parse(Console.ReadLine());
bool parsingResult = int.TryParse(Console.ReadLine(), out int winningScore);
if (!parsingResult)
{
	winningScore = 3;
}

Console.WriteLine($"Wins to win: {winningScore}");

while (firstPlayerScore < winningScore && secondPlayerScore < winningScore)
{
	Console.WriteLine("Provide sign (rock/paper/scissors)");
	string firstSign = Console.ReadLine();

	while (firstSign != "rock" && firstSign != "paper" && firstSign != "scissors")
	{
		Console.WriteLine("Wrong sign. Please provide correct sign");
		firstSign = Console.ReadLine();
	}

	Console.WriteLine("Type in your sign, second player:");
	string secondSign = Console.ReadLine();

	while (secondSign != "rock" && secondSign != "paper" && secondSign != "scissors")
	{
		Console.WriteLine("Wrong sign");
		secondSign = Console.ReadLine();
	}

	if (firstSign == secondSign)
	{
		Console.WriteLine("It's a draw");
	}
	else if ((firstSign == "rock" && secondSign == "scissors") 
			 || (firstSign == "paper" && secondSign == "rock") 
			 || (firstSign == "scissors" && secondSign == "paper"))
	{
		Console.WriteLine("First player won");
		//firstPlayerScore = firstPlayerScore + 1;
		firstPlayerScore += 1;
		//firstPlayerScore++;
	}
	else
	{
		Console.WriteLine("Second player won");
		secondPlayerScore += 1;
	}
	
	// Console.WriteLine("[Player 1] " + firstPlayerScore + " : " + secondPlayerScore + " [Player 2]");
	Console.WriteLine($"[Player 1] {firstPlayerScore} : {secondPlayerScore} [Player 2]");
}

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany. Wymagane pola są oznaczone *

Akceptuję zasady Polityki prywatności