Facebook
From AB, 2 Months ago, written in C#.
Embed
Download Paste or View Raw
Hits: 245
  1. using System;
  2.      
  3. public class Program
  4. {
  5.  public static void Main()
  6.  {
  7.   Random rand = new Random();
  8.   //Create a boolean that represents the state of the game.
  9.  
  10.   while(/*Use your game state bool here*/)
  11.   {
  12.       int target = rand.Next(1000);
  13.       //Create an integer to represent the minimum range for guesses. It should start at 0
  14.       //Create an integer to represent the maximum range for guesses. It should start at 1000
  15.    //Create an integer to represent the current guess of the player
  16.    
  17.    while(/*Insert your guess variable here*/ != target)
  18.    {
  19.     Console.WriteLine("Please Guess a number between " + /*Insert your minimum variable here*/ + " and " + /*Insert your maximum variable here*/ + "...");
  20.     /*Insert your guess variable here to assign value*/ = Convert.ToInt32(Console.ReadLine());
  21.     Console.WriteLine("You entered: " + /*Insert your guess variable here*/);
  22.    
  23.     if(/*Insert your guess variable here*/ > target)
  24.     {
  25.      Console.WriteLine("Your guess is too high!");
  26.      //Set your max variable to be equal to your guess variable
  27.     }
  28.     else if(/*Insert your guess variable here*/ < target)
  29.     {
  30.      Console.WriteLine("Your guess is too low!");
  31.      //Set your min variable to be equal to your guess variable
  32.     }
  33.    }
  34.    
  35.    Console.WriteLine("You Win!");
  36.    Console.WriteLine("Play again? Y or N");
  37.    var userInput = Console.ReadLine();
  38.    
  39.    if(userInput != "Y")
  40.    {
  41.     Console.WriteLine("Thanks for playing! Goodbye.");
  42.     //Set your game state bool to be false
  43.    }  
  44.   }
  45.  }
  46. }