4
The question is simple personal: I can have more than one constructor in the same class?
At first, I will need to define the variable plugin
in my object, then I will use the constructor that defines such a variable;
public RankAPI(Main main) {
plugin = main;
}
However, in a second moment, I will need to define a second variable, the variable p
on my object, then I will have to use the second constructor:
public RankAPI(Player player) {
p = player;
}
Unfortunately, I cannot define the two variables, because the variable p
will be defined by other programs when they need to access my API, and the variable plugin
will be defined by my own program when executed.
Thank you for your attention.
Doesn’t it make more sense to separate into different classes? With this approach you always have to check which is set and which is not. I
– Nuno Gonçalves