View Single Post
liv(int) in Liv cannot be applied to () - Java
Old
  (#1)
Zacker
Project Leader, Lead Level Designer, Waypointer
 
Status: Offline
Posts: 337
Join Date: Mar 2004
Location: Denmark
Default liv(int) in Liv cannot be applied to () - Java - 04-06-2004

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.

Last edited by Zacker; 04-06-2004 at 21:38..
  
Reply With Quote