Hi guys,
In this program for school (it's part of a bigger problem where I have to shuffle a deck)... I have to store every possible playing-card combination in an ArrayList. Now, I am a fairly new programmer, but honestly, the output here baffles me. What am I doing wrong?
package fifth_class; import java.util.ArrayList; public class CardShufflerTester { public static void main(String[] args){ ArrayList<String> cardDeck = new ArrayList(); cardDeck = initDeck(); for(int i=0;i<cardDeck.size();i++){ System.out.println(cardDeck.get(i).toString()); } } public static ArrayList<String> initDeck(){ ArrayList<String> deck = new ArrayList(); for(int i=1;i<14;i++){ String card = new String(); card = ""; switch(i){ case 1: card = card.concat("Two "); case 2: card = card.concat("Three "); case 3: card = card.concat("Four "); case 4: card = card.concat("Five "); case 5: card = card.concat("Six "); case 6: card = card.concat("Seven "); case 7: card = card.concat("Eight "); case 8: card = card.concat("Nine "); case 9: card = card.concat("Ten "); case 10: card = card.concat("Jack "); case 11: card = card.concat("Queen "); case 12: card = card.concat("King "); case 13: card = card.concat("Ace "); } for(int j=1;j<5;j++){ switch(j){ case 1: card = card.concat("of Hearts"); case 2: card = card.concat("of Diamonds"); case 3: card = card.concat("of Clubs"); case 4: card = card.concat("of Spades"); } } deck.add(card); card = ""; } return deck; } }
Thanks for any help...