コード例 #1
0
ファイル: Game.cs プロジェクト: fyv1/Higher-Lower
 public void Equals(User u, Digit d)
 {
     if (u.getInput() == d.getValue())
     {
         Console.WriteLine("Gratulacje, trafiłeś za {0} razem!", counter);
     }
     if (u.getInput() < d.getValue())
     {
         Console.WriteLine("Liczba mniejsza od oczekiwanej, próba nr: {0}", counter); counter++;
     }
     else if (u.getInput() > d.getValue())
     {
         Console.WriteLine("Liczba większa od oczekiwanej, próba nr: {0}", counter); counter++;
     }
 }
コード例 #2
0
        static void Main(string[] args)
        {
            Random r     = new Random();
            Digit  digit = new Digit(r.Next(0, 99));
            User   user  = new User();
            Game   g     = new Game();

            while (user.getInput() != digit.getValue())
            {
                Console.Write("Zgadnij liczbę!: "); user.setInput(Convert.ToInt32(Console.ReadLine()));
                g.Equals(user, digit);
            }

            Console.ReadKey();
        }