Compile error:
Code:
liv(int) in Liv cannot be applied to ()
stats_sum = styrke + intelligens + liv.liv()/10;
With a ^ below the dot.
I initialize the method/function here:
Code:
//Opret et objekt af klassen Liv
Liv liv = new Liv();
The method/function:
Code:
//Justerer eller returnerer spillerens liv
public int liv(int a)
{
if(a!=0)
{
//Giver spilleren a mere i liv, hvis a ikke er 0
liv = liv + a;
System.out.println("Du har nu " + liv + " i liv");
}
else
{
//Returnerer værdien af liv til den kaldende funktion
return liv;
}
}
I hope it obvious that I just want the value of liv
Edit:
It works if I call it with the parameter 0. Then I thought it would help initializing the variable in the method, like this:
public int liv(int a=0)
That just resulted in a bunch of compile errors.