I'm new to java programming and have started creating a poker game. So far have have the cards and deck created but I want to be able to select a random card but I don't want to shuffle the deck.
This is my code so far:
import java.util.ArrayList;
import java.util.List;
public class PockerMain {
public PockerMain() {
// TODO Auto-generated constructor stub
}
public static void main(String[] args) {
List<PokerCard> deck = cardDeck();
for (int i = 0; i < deck.size(); i ++)
{
PokerCard card = deck.get(i);
System.out.println(card);
}
}
private static PokerCard createCard (short suit, short rank)
{
PokerCard card = new PokerCard (suit, rank);
return card;
}
private static List<PokerCard> cardDeck ()
{
List<PokerCard> deck = new ArrayList<PokerCard> ();
for (int i = 0; i < 4; i ++)
{
for (int j = 0; j < 13; j ++)
{
PokerCard card = createCard ((short)i, (short)j);
deck.add(card);
}
}
return deck;
}
}
Aucun commentaire:
Enregistrer un commentaire