Advertisement
Guest User

Untitled

a guest
May 25th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Kompletteringsgrejen
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. // binder orden maxgräns (5).
  15. string[] OrdVal = new string[5];
  16. int Ordlägg = 0;
  17.  
  18. // loop
  19. while(true)
  20.  
  21.  
  22. // Menyval
  23. {
  24. Console.WriteLine("\n\t**** GISSA ORDET ****");
  25. Console.WriteLine("\t[1]Mata in ord");
  26. Console.WriteLine("\t[2]Till spelet");
  27. Console.WriteLine("\t[3]Avsluta program");
  28. Console.Beep();
  29.  
  30.  
  31. string menyVal = Console.ReadLine();
  32.  
  33. if (menyVal == "1")
  34.  
  35. while(Ordlägg < OrdVal.Count()) // Loopas till 5 ord är skrivna.
  36. {
  37. Console.Beep ();
  38. Console.WriteLine("\n\n\t=== MATA IN ORD ===\n\t"); // Koden för ord-inmatning.
  39. Console.WriteLine("Ord: ");
  40. OrdVal[Ordlägg] = (Console.ReadLine());
  41. Console.WriteLine("Ordet är nu tillagt");
  42. Console.ReadKey();
  43. Ordlägg++;
  44. }
  45.  
  46.  
  47. if (menyVal == "2")
  48. {
  49. Console.Beep();
  50. Console.WriteLine("\n\n\t === GISSA ORDET === \n\t"); // koden för att gissa ordet.
  51. Console.WriteLine("Mata in gissning: ");
  52. string Figissning = Console.ReadLine();
  53. foreach (var FiOrd in OrdVal)
  54. {
  55. if (FiOrd == Figissning)
  56. {
  57. Console.WriteLine("Korrekt gissat.");
  58. }
  59. else
  60. {
  61. Console.WriteLine("Gissning inkorrekt, försök igen.");
  62. Console.ReadLine();
  63. Console.ReadKey();
  64. }
  65.  
  66. }
  67.  
  68.  
  69. }
  70.  
  71.  
  72. if (menyVal == "3")
  73. {
  74.  
  75. break; // Avbryter while loopen, spelet avslutas
  76. }
  77. else
  78. {
  79. Console.WriteLine("Ogiltligt val!");
  80. }
  81. }
  82.  
  83.  
  84.  
  85.  
  86.  
  87. }
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement