Reputation: 13
private static long CalculateScore(byte chances, long millisec) { int score; byte num1 = chances++; byte num2 = (byte)10; byte num3 = (byte)10; switch (Program.currLevelIndex) { case (byte)7: num2 = (byte)10; break; case (byte)11: num2 = (byte)20; break; case (byte)15: num2 = (byte)40; break; }
if ((int)chances >= 1 && (int)chances <= 3)
num1 = (byte)40;
else if ((int)chances >= 4 && (int)chances <= 6)
num1 = (byte)20;
else if ((int)chances > 7)
num1 = (byte)10;
if (millisec > 480000L)
num3 = (byte)10;
else if (millisec >= 240000L && millisec <= 480000L)
num3 = (byte)20;
else if (millisec < 240000L)
num3 = (byte)40;
try
{
score = Convert.ToInt32((int)num2 * (int)num1 * (int)num3);
}
catch
{
score=0;
}
Console.SetCursorPosition(Program.x, Program.y);
Console.Write("Your Score was: " + score);
}`
The error is CalculateScore & I can't find the mistake. this is a method is to work ou Help is nedeed.
Upvotes: 1
Views: 103
Reputation: 23113
private static long CalculateScore
expects a return value of type long, but your method does not return anything.
Add the following to the end of the method.
return score;
And you might want to change the return type to int
or the score variable to long
private static int CalculateScore(byte chances, long millisec)
{
int score;
byte num1;
Or
private static long CalculateScore(byte chances, long millisec)
{
long score;
byte num1;
Upvotes: 2
Reputation: 28762
You specified that the function will return a value of type long
, but there is no return statement returning a value at the end of the function
You need to add
return score;
as score
is the result of the calculation
Upvotes: 0