wotsits
October 12th, 2009, 08:50 AM
I'm making a hanafuda game (Japanese type card game).
public static void main(String[] args) {
ArrayList<Card> deck = new ArrayList<Card>();
Card janbright = new Card();
janbright.month = "January";
janbright.flower = "Pine";
deck.add(janbright);
Card janpoemscr = new Card();
janpoemscr.month = "January";
janpoemscr.flower = "Pine";
deck.add(janpoemscr);
Card janbasic1 = new Card();
janbasic1.month = "January";
janbasic1.flower = "Pine";
deck.add(janbasic1);
etc etc, this goes on for 48 cards. So then I do
Collections.shuffle(deck);
And now, I want to pass 8 cards in to player1's hand, 8 to the table, and 8 to player2's hand. All of these collections have constantly changing sizes so I need something (i guess) like 3 arraylists, one for player1, one for player2, one for the table.
So my question is - Now that I have shuffled the deck, how do i 'select' index 0 through index 7, then index 8 through 15, then 16 through 23, and pass the objects in those indexes in to the other arraylists? Because the deck has been shuffled, I know that I have those indexes, but I dont know which object is in each index.
public static void main(String[] args) {
ArrayList<Card> deck = new ArrayList<Card>();
Card janbright = new Card();
janbright.month = "January";
janbright.flower = "Pine";
deck.add(janbright);
Card janpoemscr = new Card();
janpoemscr.month = "January";
janpoemscr.flower = "Pine";
deck.add(janpoemscr);
Card janbasic1 = new Card();
janbasic1.month = "January";
janbasic1.flower = "Pine";
deck.add(janbasic1);
etc etc, this goes on for 48 cards. So then I do
Collections.shuffle(deck);
And now, I want to pass 8 cards in to player1's hand, 8 to the table, and 8 to player2's hand. All of these collections have constantly changing sizes so I need something (i guess) like 3 arraylists, one for player1, one for player2, one for the table.
So my question is - Now that I have shuffled the deck, how do i 'select' index 0 through index 7, then index 8 through 15, then 16 through 23, and pass the objects in those indexes in to the other arraylists? Because the deck has been shuffled, I know that I have those indexes, but I dont know which object is in each index.