I tried to make an basic number-guessing game. However I couldn't find the way that I keep the randomized number constant in order to give clues to user to increase or decrease his/her guess.This is so easy for you but I need your valuable and useful perspectives. PS: Yeah I am a beginner.
while (true)
{
Random rd = new Random();
Console.WriteLine("guess a number 0-10");
guess = int.Parse(Console.ReadLine());
comp = rd.Next(10);
if (guess == comp)
{
Console.WriteLine("congratz!! u won!!");
Console.WriteLine("press any key to exit");
break;
}
// Those are the conditions for directing user.I couldn't implement it.
//else if (guess > comp)
// Console.WriteLine("your guess is greater than my number, yow!");
//else if (guess < comp)
// Console.WriteLine("your guess is lower than my number, yow!");
Console.WriteLine("loser!!" + "My number was:" + comp);
}
Console.ReadLine();
Aucun commentaire:
Enregistrer un commentaire