I've been searching around for a few minutes and wasn't able to find a question that resembles mine. Just in case if this is a question that has been asked before, I am sincerely sorry and it's unintentional.
I'm trying to change the static variable's value that is passed in as a parameter. So there is this block of code:
public int check(int row, int column, char ch, Color color, int score) {
this.row = row;
this.column = column;
this.ch = ch;
this.color = color;
this.score = score;
flag = 0;
if (something){
do stuff
score++;
}
}
and there are these static variables are passed in for int score:
public static int player1Score;
public static int player2Score;
The method is supposed to be called via an event handler, and the button that they press determine whether the player1Score or the player2Score is passed as a parameter. It would be easy if it was just a single variable that is being passed as a parameter, but it is two or more at this point and can't think of any other way except making duplicate if-statements and each having them as player1Score++ and playr2Score++.
There are like 35 if statements that check the condition to do score++, and I just wanted to ask as if there is a way to change the value of the parameter itself.
Two static score variables are in a different class.
Help would be very appreciated.
Thanks.