Files
2026-11-17 15:55:29 -03:00

47 lines
1.1 KiB
C#

namespace ConsoleApp2;
class Program
{
static void Main()
{
int numerodetentativas = 0;
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.WriteLine("Qual o animal secreto?");
string tentativa = Console.ReadLine();
string animalsecreto = "gato";
while (tentativa != "gato")
{
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("Errou!");
tentativa = Console.ReadLine();
numerodetentativas++;
}
Program.VerificarAnimal(tentativa, animalsecreto, numerodetentativas);
}
static bool VerificarAnimal(string tentativa, string animalsecreto, int numerodetentativas)
{
if (tentativa == animalsecreto)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Acertou!");
Console.ForegroundColor = ConsoleColor.DarkBlue;
Console.WriteLine($"Voce acertou em {numerodetentativas} tentativas");
return true;
}
return false;
}
}