Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Deck() {
- cards = new Card[52];
- int i = 0;
- for (int suit = 0; suit < 4; suit++){
- for (int cardValue = 1; cardValue < 14; cardValue++){
- cards[i] = new Card(cardValue, suit);
- i++;
- }
- }
- }
- public Deck(Deck other) {
- //the cards array is a private variable. so u cant access length or a particular card directly. thats why we have written getters for it.
- //use that to find length and access a card
- cards = new Card[other.cards.length];
- for (int i = 0; i < other.cards.length; i++){
- cards[i] = other.cards[i];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement