-
creating public objects
I have a class called Parameters, like so:
Code:
public class Parameters {
public enum region {
A, B, C, D, E
}
public enum playerColour {
RED, BLUE, GREEN, YELLOW, PURPLE, BLACK, WHITE, FREE
}
public enum Fuel_Type {
URANIUM, COAL, OIL, HYBRID, GARBAGE, RENEWABLE
}
/*Constants*/
public static final int COAL_TOTAL=24;
public static final int OIL_TOTAL=24;
public static final int URANIUM_TOTAL=12;
public static final int GARBAGE_TOTAL=24;
public static final int CASH_START=50;
public static final int[] PAYOUT={10,22,33,44,54,64,73,82,90,98,105,112,118,124,129,134,138,142,145,148,150};
/*Variables*/
public Power_Stations[] stockStations;
public int numberPlayers;
public int numberRegions;
public int Step;
Then I tried to make a public instance of the class like so:
Code:
public Parameters parameters=new Parameters();
I was rather hoping that this would mean that I could use this instance in my other classes where I'm constructing methods that use the parameters varaiables. Where am I going wrong?
-
If I understand correctly, you want a global varible. Java doesn't have them, so you'll need to pass your Parameters varible to an object that needs to interact with it.
-