Assuming I am working on creating a deck of cards game, I have two methods called shuffle and randomInt in my class.
private static void shuffle(Card [] cardArray) {
for (int i = 1; i <= 20; s++) {
Card temp = cardArray[a];
cardArray[a] = cardArray[b];
cardArray[b] = temp;
}
}
private static void randomInt(int a, int b) {
a = (int)(Math.random() * 12);
b = (int)(Math.random() * 12);
}
Question here is how can I pass the variable a
and b
from method randomInt()
into the shuffle()
method? I understand that I can simply put in this randomInt()
inside shuffle()
and it will work fine, but I will like to know if there is any way to do it this way.
Will appreciate for someone to explain on the concept too as I am fairly new to OOP. Thank you.