Reputation: 21
I am creating a card game (blackJack) in android. the first two cards are easy card1 and card2, however i want to press a Hit me button and deal a new card and assign it to card3, card4 etc is there any way to do this without essentially creating the maximum number of variables you would need and using if then statements to check if they have been assigned a value or not?
Upvotes: 1
Views: 883
Reputation: 15052
Use a List
to keep track of your dealt cards instead of having individual variables.
private List<Card> dealtCard = new LinkedList<Card>();
you can then add and remove your cards easily,and dynamically.
Upvotes: 6