I have a class in which I have declared a boolean value, like so.
Class1:
Code:
public static boolean GLOBAL_PVP = false;
And in this class, I have created a method to return the boolean. I have done this so that I can import Class1 into Class2, and have Class2 read the boolean's value.
Class1:
Code:
public static boolean GLOBAL_PVP = false;
public static boolean GlobalPvp () {return GLOBAL_PVP;}
I read some material on stackoverflow that seemed to suggest this was a poor way of handling booleans, but I don't know how else to do it.
I can then access the boolean GLOBAL_PVP from Class2 like so:
Class2:
Code:
if (Class1.GlobalPvp()) {
return true;
}
(this is inside yet another boolean that determines if combat is possible or not. I wish to be able to override this check if global PvP is enabled, and thus, GLOBAL_PVP is true.)
***
Here's where I'm stuck. I can get the value just fine. But how do I set the value of GLOBAL_PVP from Class2?
Thanks for any light you can shed, I'm very new at Java.