@didiwka
Начала изучать IT

Почему я получаю ошибку «no overload method takes 0 arguments»?

using System;
namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            Random rnd = new Random();
            Console.WriteLine("---   Start Game   ---");
            Console.Write("\nPredict the points number (2..12) : ");

            int predict = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("User rolls the dice: " + predict + "\n");

            int summa = sum(RollTheDice(), RollTheDice());
            int score = summa - Math.Abs(summa - predict) * 2;

            Console.WriteLine("\nOn the dice fell {0} points", summa);
            Console.WriteLine("\nResult {0}-abs({0}-{1})*2: {2} points", summa, predict, score);

            if (score > 0)
            {
                Console.WriteLine("\nUser wins!.");
            }
            else
            {
                Console.WriteLine("\nUser lose!");
            }
        }
        public int RollTheDice(int number)
        {
            Random rnd = new Random();
            number = rnd.Next(1, 7);
            Printdice(number);
            return number;
        }
        public int sum(int n1, int n2)
        {
            return n1 + n2;
        }
        static void Printdice(int number)
        {
            switch (number)
            {
                case 1:
                    Console.WriteLine("---------");
                    Console.WriteLine("|       |");
                    Console.WriteLine("|   #   |");
                    Console.WriteLine("|       |");
                    Console.WriteLine("---------");
                    break;
                case 2:
                    Console.WriteLine("---------");
                    Console.WriteLine("| #     |");
                    Console.WriteLine("|       |");
                    Console.WriteLine("|     # |");
                    Console.WriteLine("---------");
                    break;
                case 3:
                    Console.WriteLine("---------");
                    Console.WriteLine("| #     |");
                    Console.WriteLine("|   #   |");
                    Console.WriteLine("|     # |");
                    Console.WriteLine("---------");
                    break;
                case 4:
                    Console.WriteLine("---------");
                    Console.WriteLine("| #   # |");
                    Console.WriteLine("|       |");
                    Console.WriteLine("| #   # |");
                    Console.WriteLine("---------");
                    break;
                case 5:
                    Console.WriteLine("---------");
                    Console.WriteLine("| #   # |");
                    Console.WriteLine("|   #   |");
                    Console.WriteLine("| #   # |");
                    Console.WriteLine("---------");
                    break;
                case 6:
                    Console.WriteLine("---------");
                    Console.WriteLine("| # # # |");
                    Console.WriteLine("|       |");
                    Console.WriteLine("| # # # |");
                    Console.WriteLine("---------");
                    break;
            }
        }
    }
}
  • Вопрос задан
  • 192 просмотра
Решения вопроса 1
Griboks
@Griboks Куратор тега C#
int summa = sum(RollTheDice(), RollTheDice());
...
public int RollTheDice(int number)

Как видите, вы забыли в скобках указать аргумент.
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
freeExec
@freeExec
Участник OpenStreetMap
Потому что ты забыл написать метод который вызываешь.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы