I'm trying to work on an app/small game that is about trying to guess the same number between 1-10 same as the program and win, but after that round you are supposed to be able to play again! My problem is that the program generates the same number everytime. I have looked through other threads on here and none of them seem to help or at least I cannot understand them. How can I fix this?
static void Main(string[] args)
{
Random random = new Random();
bool play = true;
int playnum = random.Next(1, 11);
while (play)
{
Console.Write("\n\tGuess number between 1-10 ");
int numb;
bool success = Int32.TryParse(Console.ReadLine(), out numb);
if (success)
{
if (numb < playnum)
{
Console.WriteLine(playnum);
Console.WriteLine("\tinput number " + numb + " too small, try again.");
}
if (numb > playnum)
{
Console.WriteLine(playnum);
Console.WriteLine("\tinput number " + numb + " too big, try again.");
}
if (numb == playnum)
{
Console.WriteLine(playnum);
Console.WriteLine("\tcongrats!");
bool LoopBreaker = true;
do
{
Console.WriteLine("continue or finish?");
string input = Console.ReadLine();
char CharFromTryPass = ' ';
bool TryparsResult = char.TryParse(input, out CharFromTryPass);
bool IsValidChar = (CharFromTryPass != 'A' && CharFromTryPass != 'F');
if (IsValidChar)
{
Console.WriteLine(" please write A or F!");
}
else if (TryparsResult)
{
if (CharFromTryPass == 'A')
{
Console.WriteLine("see you!");
play = false;
LoopBreaker = false;
}
if (CharFromTryPass == 'F')
{
play = true;
LoopBreaker = false;
}
}
} while (LoopBreaker);