Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.31 KB | None | 0 0
  1. using System;
  2. using System.Collections.ObjectModel;
  3. using System.Runtime.InteropServices;
  4.  
  5. namespace Basics
  6. {
  7. class Program
  8. {
  9. static void Parrot(int count, string str)
  10. {
  11. int i = 0;
  12. while (i<count )
  13. {
  14. Console.WriteLine(str);
  15. i++;
  16. }
  17. }
  18.  
  19.  
  20. static void Introduction(string name, uint age, string city, string work)
  21. {
  22. Console.WriteLine("Hello, my name is " + name + ", I am " + age + ", I live in" + city + " and I work in " +
  23. work);
  24. }
  25. public static void Ground()
  26. {
  27. string bas = @"
  28. | _ |
  29. | | | |
  30. |____|_|____|";
  31.  
  32. Console.WriteLine(bas);
  33. }
  34.  
  35. public static void Roof()
  36. {
  37. string toit = @"
  38. ___________
  39. | |";
  40. Console.Write(toit);
  41. }
  42.  
  43. public static void Floor(int nb)
  44. {
  45. string etage = @"
  46. | _ _ |
  47. | |o| |o| |
  48. | |_| |_| |";
  49. int i = 0;
  50. while (i<nb)
  51. {
  52. Console.Write(etage);
  53. i = i + 1;
  54.  
  55. }
  56. }
  57.  
  58. public static bool CheckNumber(int input, int number)
  59. {
  60.  
  61. {
  62.  
  63. if (input > number)
  64. {
  65. Console.ForegroundColor = ConsoleColor.Red;
  66. Console.WriteLine("The correct number is inferior to " + input);
  67. return false;
  68. }
  69. else if (input < number)
  70. {
  71. Console.ForegroundColor = ConsoleColor.Red;
  72. Console.WriteLine("The correct number is superior to " + input);
  73. return false;
  74. }
  75. else
  76. {
  77. Console.ForegroundColor = ConsoleColor.Green;
  78. Console.WriteLine("Congratulation, the number was: " + number);
  79. return true;
  80. }
  81. }
  82. }
  83.  
  84. public static bool Game(int number, int tries)
  85. {
  86. int resultat = number;
  87.  
  88. while (tries>0)
  89. {
  90. Console.WriteLine("Saisir un nombre :");
  91. int nb = Convert.ToInt32(Console.ReadLine());
  92. if (CheckNumber(nb,resultat))
  93. {
  94. return true;
  95. }
  96. tries--;
  97. Console.ForegroundColor = ConsoleColor.Black;
  98. Console.WriteLine("x tries left:" + tries );
  99.  
  100. }
  101. Console.ForegroundColor = ConsoleColor.Red;
  102. Console.WriteLine("The correct number was "+ resultat);
  103. return false;
  104.  
  105. }
  106.  
  107. public static void difficulties()
  108. {
  109. string ez = "easy";
  110. string med = "medium";
  111. string hard = "hard";
  112. int nb;
  113. Random rnd = new Random();
  114. Console.WriteLine("Choisir la difficultes : (easy/medium/hard)");
  115. string choice = Console.ReadLine();
  116. if (choice==ez)
  117. {
  118.  
  119. nb = rnd.Next(0,10);
  120. Game(nb, 5);
  121. }
  122. else if (choice==med)
  123. {
  124. nb = rnd.Next(0,100);
  125. Game(nb, 15);
  126. }
  127. else if (choice==hard)
  128. {
  129. nb = rnd.Next(0, 1000);
  130. Game(nb, 20);
  131. }
  132.  
  133. }
  134.  
  135. public static void TheGame()
  136. {
  137. string the = @"
  138. ________ __ __ ________
  139. | \| \ | \| \
  140. \$$$$$$$$| $$ | $$| $$$$$$$$
  141. ______ ______ | $$ | $$__| $$| $$__
  142. | \| \| $$ | $$ $$| $$ \
  143. \$$$$$$ \$$$$$$| $$ | $$$$$$$$| $$$$$
  144. | $$ | $$ | $$| $$_____
  145. | $$ | $$ | $$| $$ \
  146. \$$ \$$ \$$ \$$$$$$$$
  147. ";
  148.  
  149. string game = @"
  150. ______ ______ __ __ ________
  151. / \ / \ | \ / \| \
  152. | $$$$$$\| $$$$$$\| $$\ / $$| $$$$$$$$
  153. | $$ __\$$| $$__| $$| $$$\ / $$$| $$__ ______ ______
  154. | $$| \| $$ $$| $$$$\ $$$$| $$ \| \| \
  155. | $$ \$$$$| $$$$$$$$| $$\$$ $$ $$| $$$$$ \$$$$$$ \$$$$$$
  156. | $$__| $$| $$ | $$| $$ \$$$| $$| $$_____
  157. \$$ $$| $$ | $$| $$ \$ | $$| $$ \
  158. \$$$$$$ \$$ \$$ \$$ \$$ \$$$$$$$$
  159. ";
  160. Console.ForegroundColor = ConsoleColor.Magenta;
  161. Console.Write(the);
  162. Console.ForegroundColor = ConsoleColor.Blue;
  163. Console.Write(game);
  164. Console.ForegroundColor = ConsoleColor.Green;
  165. Console.WriteLine();
  166. Console.WriteLine(" Choisir un mode : (solo/multi)");
  167. string rep = Console.ReadLine();
  168. string solo = "solo";
  169. string multi = "multi";
  170.  
  171. if (rep == solo)
  172. {
  173. difficulties();
  174. }
  175.  
  176. if (rep== multi)
  177. {
  178. Console.WriteLine("Choisir votre nombre puis votre nombre d'essaie :");
  179. int nombre = Convert.ToInt32(Console.ReadLine());
  180. int essaie = Convert.ToInt32(Console.ReadLine());
  181. Console.Clear();
  182. Console.WriteLine("Le jeu demare :");
  183. Game(nombre, essaie);
  184. }
  185.  
  186. }
  187.  
  188. static void Main(string[] args)
  189. {
  190. TheGame();
  191. }
  192. }
  193. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement