Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ___________
- Program.cs
- ___________
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Ratespiel
- {
- class Program
- {
- public static void Main(string[] args)
- {
- Random rnd = new Random();
- int nummer = rnd.Next(1, 100);
- int zahlRaten = Mechanik.GetNumber();
- Mechanik.Raten(zahlRaten, nummer);
- Console.ReadKey();
- }
- }
- }
- ________________
- Mechanik.cs
- ________________
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Ratespiel;
- namespace Ratespiel
- {
- class Mechanik
- {
- public static int GetNumber()
- {
- Console.WriteLine("Errate die Zahl: ");
- int zahl;
- zahl = Int32.Parse(Console.ReadLine());
- return zahl;
- }
- public static void Raten(int a, int b)
- {
- while (a != b)
- {
- if (a < b)
- {
- Console.WriteLine("Höher");
- a = Int32.Parse(Console.ReadLine());
- }
- else
- {
- Console.WriteLine("Niedriger");
- a = Int32.Parse(Console.ReadLine());
- }
- }
- while (a == b)
- {
- Console.WriteLine("Korrekt!");
- Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement