View Single Post
Re: Calling methods from different classes
Old
  (#3)
Zacker
Project Leader, Lead Level Designer, Waypointer
 
Status: Offline
Posts: 337
Join Date: Mar 2004
Location: Denmark
Default Re: Calling methods from different classes - 12-06-2004

The method declaration lies within Race.Java
Quote:
//Justerer eller returnerer spillerens liv
public int fixliv(int a)
{
if(a!=0)
{
//Giver spilleren a mere i liv
liv = liv + a;
System.out.println("Du har nu " + liv + " i liv");
}
else
{
//Returnerer værdien af liv
return liv;
}
return 0;
}
First it gets called in Race.java
Quote:
fixliv(100);

Then I declare a new instance of the class Race in Sted.java:
Quote:
//Race
//Opret et objekt af klassen Race
Race race = new Race();
And then I call it in Sted.java:
Quote:
race.fixliv(10);
  
Reply With Quote