i created 52 cards objects from my clsCard. i.e.
dim twoOfHearts as new clsCard
twoOfHearts.facevalue = "2"
twoOfHearts.suit = "Hearts"
now i want to add them to my deck (52) as clsCard.
what's the easiest way to add them iteratively?
Printable View
i created 52 cards objects from my clsCard. i.e.
dim twoOfHearts as new clsCard
twoOfHearts.facevalue = "2"
twoOfHearts.suit = "Hearts"
now i want to add them to my deck (52) as clsCard.
what's the easiest way to add them iteratively?
Eep you will be better off recreating your cards a different way. I'm not familiar with ENUMS but every example for a deck of cards uses them. I'm assuming you have 52 cards name faceValueOfDeck? Having it set up this way will require you to add each one individually to an array(or arrayList)
If you redo it and have 52 card objects you can have a for loop that creates them within the loop while adding them.
I'm sure you can work some better logic into to determine the face values(like x%13 == 0 then value = ace)Code:for(1 to 52){
if(x > 0 && x <= 13)
if(x == 10)
value = "jack";
else if(x == 11)
value = "queen";
else if(x == 12)
value = "king";
else if(x == 13)
value = "ace";
else{
value = x;
deck[x] = new Card("Clubs",value);
}
.......
}
Hope this helps