I am creating a basic top trumps app in android development. I only need 6 top trumps card which have been made by using a database. I already have the code for this and have successfully created the cards.
I am stuck on this bit
When the user selects Play you should randomly assign half of the cards in the database to the human player, and half of the cards to the computer.
And was wondering if anyone had any ideas on how to do this? Thanks everyone.
UPDATE
I have tried doing this
ArrayList<Integer> cards = new ArrayList<Integer>();
for(int i=1;i<=6;i++)
{
this.cards.add(i);
}
Collections.shuffle(this.cards);
To shuffle the cards but I’m unsure on how to assign the computer and user the cards.
I’m not sure what you are aiming for here, but would something like this do (after you have shuffled):
Of course, you should use variables instead of constants everywhere, but you get the idea.