I've killed so many hours for something almost insignificant. I just don't know how to continue with this matter. I did this whole guessing game thing here, but what I need to do to finish it is to make it say if it's warm, hot, cold, colder, etc when the guess comes closer or farther from the randomly generated number. The "warm,hot, cold" part from the code is just to understand, but I actually need to make it more complicated and add these:
<= 3 - very hot
<= 5 - hot
<= 10 - warmer
<= 20 - warm
<= 50 - cold
<= 99 - colder
int number;
Random n = new Random();
int guessNumber = n.Next(1, 100);
uint entries = 0;
int difference = 0;
Console.WriteLine("It's time to choose Mr.Freeman. Pick a number between 0-100.");
do
{
do
{
number = int.Parse(Console.ReadLine());
if((number < 0) || (number > 100))
{
Console.WriteLine("The number must be between 0 and 100.");
}
}
while ((number < 0) || (number > 100));
Console.WriteLine(guessNumber);
if(number > guessNumber)
{
difference = (guessNumber - number);
}
else if (number < guessNumber)
{
difference = (number - guessNumber);
}
int onlyPositive = Math.Abs(difference);
if (number == guessNumber)
{
Console.WriteLine("Splendid Mr.Freeman. You are indeed lucky.");
}
else if ((onlyPositive - number) <= 50)
{
Console.WriteLine("Cold! Try again!");
}
else if ((onlyPositive - number) <= 25)
{
Console.WriteLine("Warm! Try again!");
}
else if ((onlyPositive - number) <= 10)
{
Console.WriteLine("Hot! Try again!");
}
entries++;
}while (number != guessNumber);
Console.WriteLine("Entries : " + entries);
Console.ReadLine();
Aucun commentaire:
Enregistrer un commentaire