Advertisement
MeckeOfficial

Rate zwischen 0 und 100

Sep 8th, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.61 KB | None | 0 0
  1. ___________
  2. Program.cs
  3. ___________
  4.  
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10.  
  11. namespace Ratespiel
  12. {
  13.     class Program
  14.     {
  15.         public static void Main(string[] args)
  16.         {
  17.        
  18.  
  19.             Random rnd = new Random();
  20.             int nummer = rnd.Next(1, 100);
  21.  
  22.             int zahlRaten = Mechanik.GetNumber();
  23.  
  24.             Mechanik.Raten(zahlRaten, nummer);
  25.  
  26.             Console.ReadKey();
  27.  
  28.  
  29.         }
  30.     }
  31. }
  32.  
  33. ________________
  34. Mechanik.cs
  35. ________________
  36.  
  37. using System;
  38. using System.Collections.Generic;
  39. using System.Linq;
  40. using System.Text;
  41. using System.Threading.Tasks;
  42. using Ratespiel;
  43.  
  44. namespace Ratespiel
  45. {
  46.     class Mechanik
  47.     {
  48.         public static int GetNumber()
  49.  
  50.         {
  51.  
  52.             Console.WriteLine("Errate die Zahl: ");
  53.             int zahl;
  54.             zahl = Int32.Parse(Console.ReadLine());
  55.  
  56.             return zahl;
  57.  
  58.         }
  59.  
  60.         public static void Raten(int a, int b)
  61.         {
  62.             while (a != b)
  63.             {
  64.  
  65.                 if (a < b)
  66.                 {
  67.                     Console.WriteLine("Höher");
  68.                     a = Int32.Parse(Console.ReadLine());
  69.  
  70.                 }
  71.  
  72.                 else
  73.                 {
  74.                     Console.WriteLine("Niedriger");
  75.                     a = Int32.Parse(Console.ReadLine());
  76.  
  77.                 }
  78.             }
  79.  
  80.             while (a == b)
  81.             {
  82.  
  83.                     Console.WriteLine("Korrekt!");
  84.                     Console.ReadLine();
  85.             }
  86.         }
  87.  
  88.  
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement