What I wanted to do was use a variable from the vehicle class (vehicle1.fuel) in a method called showInventory(). I'll try to simplify the code from the Player class:
public class Player {
int money = 500;
int resources = 100;
public void showInventory() {
System.out.println("Money: " + money);
System.out.println("Resources: " + resources);
System.out.println("Fuel: " vehicle1.fuel); // <-- How would I do this correctly?
}
}
I have no idea what I should do. I tried instantiating the vehicle class in the Player class as well, and that made it work, but I know that would not end up working when I begin changing the value of vehicle1.fuel.
This post has been edited by AVReidy: 26 July 2011 - 01:16 PM

New Topic/Question
Reply



MultiQuote







|