fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace guess_the_number
  8. {
  9. class MainClass
  10. {
  11. private Random random = new Random();
  12.  
  13. int getRandomNumber()
  14. {
  15. return random.Next(1, 100);
  16. }
  17.  
  18. void showStartText()
  19. {
  20. Console.Write("~~~Guess-The-Number~~~\n\n\n");
  21. //
  22. //
  23. Console.Write("Instructions:\n\n\n");
  24. //
  25. //
  26. Console.Write("You will attempt to guess a number, 1-100.\n");
  27. Console.Write("To guess the number, type it, then press enter.\n");
  28. Console.Write("After each guess, you will be told if the number is higher or lower than your \nguess.\n\n");
  29. }
  30.  
  31.  
  32.  
  33. static void Main(string[] args)
  34. {
  35. MainClass main = new MainClass();
  36.  
  37. //current number that is being guessed
  38. int randomNumber;
  39.  
  40. //users guess
  41. int guess;
  42.  
  43. //starting text
  44. main.showStartText();
  45.  
  46. //main game loop
  47. while (true)
  48. {
  49. //get new random number
  50. randomNumber = main.getRandomNumber();
  51.  
  52. //per-guess loop
  53. while (true)
  54. {
  55. Console.Write("Please enter your guess:");
  56.  
  57. //get valid guess - parses to make return an int, always valid input
  58. guess = main.getValidGuess();
  59. }
  60. }
  61.  
  62.  
  63. for (int i = 0; i < 100; ++i)
  64. Console.WriteLine(main.getRandomNumber());
  65.  
  66. Console.Read();
  67.  
  68. }
  69. }
  70. }
  71.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(5,24): error CS0234: The type or namespace name `Tasks' does not exist in the namespace `System.Threading'. Are you missing an assembly reference?
Compilation failed: 1 error(s), 0 warnings
stdout
Standard output is empty