Answer the question
In order to leave comments, you need to log in
Why am I getting "no overload method takes 0 arguments" error?
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;
}
}
}
}
Answer the question
In order to leave comments, you need to log in
int summa = sum(RollTheDice(), RollTheDice());
...
public int RollTheDice(int number)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question