I keep looking through the code for this, but I can't find anything that would seem off. I'm new to programming so maybe I'm missing something obvious, but any help would be appreciated. The assignment I'm working on is to make a 52 card deck and then design methods to change the deck, the cards are being created but are not being added to the ArrayList. My code for the deck class is:
import java.util.*;
public class FiftyTwoCardDeck
{
List<Card> totalDeck = new ArrayList<>();
private int deckSize = totalDeck.size();
public FiftyTwoCardDeck()
{
for(int j=0;j<4;j++) {
for(int k=0;k<13;k++) {
String s;
String c;
switch(j) {
case 0:
s = "Spades";
break;
case 1:
s = "Diamonds";
break;
case 2:
s = "Clubs";
break;
case 3:
s = "Hearts";
break;
}
switch(k) {
case 0:
c = "Ace";
break;
case 10:
c = "Jack";
break;
case 11:
c = "Queen";
break;
case 12:
c = "King";
break;
default:
c = ""+(k+1);
break;
}
Card card = new Card(s, c);
totalDeck.add(card);
}
}
}
public int cardAmount()
{
return deckSize;
}
}
The tester class just creates an object:
public class FiftyTwoCardDeckTester
{
public static void main(String args[])
{
FiftyTwoCardDeck deck = new FiftyTwoCardDeck();
}
}
And the card class that makes objects for the deck is:
import java.util.*;
public class Card
{
public Card(String st, String ct)
{
suit = st;
count = ct;
}
public String getSuit()
{
return suit;
}
public String getCount()
{
return count;
}
public String suit;
public String count;
}