guessinggamenearlydone

CSharp · Console

/Program.cs

using System;
using System.Linq;
using System.Collections.Generic;

public class Program
{
	public static void Main()
	{
		var randomNumber = new Random();
        var rnd = randomNumber.Next(1, 7);
        var userInput1 = new int ();
        Console.WriteLine("Please select a number between 1 and 6");
        bool gamestate1 = true;
        string restart = Console.ReadLine();
    	while (gamestate1 == true)
        {
        randomNumber = new Random();
        rnd = randomNumber.Next(1, 7);
        userInput1 = new int ();
        Console.WriteLine("Please select a number between 1 and 6");
        bool conversionSuccessful = int.TryParse(Console.ReadLine(), out userInput1);
        while (conversionSuccessful == false)
        {
            Console.WriteLine("Invalid entry, please try again.");
            conversionSuccessful = int.TryParse(Console.ReadLine(), out userInput1);
        }

        while (userInput1 <= 1 || userInput1 >= 6)
        {
            Console.WriteLine("nah try again young blood, please follow the directions");
            conversionSuccessful = int.TryParse(Console.ReadLine(), out userInput1);
        }

        if (rnd == userInput1)
        {
            Console.WriteLine("Correct");
        }
        else
        {
            Console.WriteLine("Wrong! The correct answer was " + rnd);
        }

        Console.WriteLine("Press y to Play again!");
        restart = Console.ReadLine();
        }
        if (restart != "y")
        {
            gamestate1 = false;
            Console.WriteLine("thanks for playing fuckboi");
        }
        }
}
;