im getting ruby down and i like it so far,
but i need a lil helping out...
i got to make a deck of cards for hw ( so dont spoil the fun and figure it out for me, just push me in the right direction )
i have set up two arrays to combine on top of eachother to create each individual card.... as seen below
SUIT = %w[ heart, diamond, club, spade ] VALUE = %w[ 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A ] SUIT.each do |suit| VALUE.each do |value| puts value + suit end end
now, when this outputs does it make a new array that i can access or is there a way i can convert that into an array,
because somehow i need to get at these cards and then be able to shuffle the deck and draw random ones off the top.
thanks in advance.
oh yeah,
here is the output from the part i have done :
2,heart,
3,heart,
4,heart,
5,heart,
6,heart,
7,heart,
8,heart,
9,heart,
10,heart,
J,heart,
Q,heart,
K,heart,
Aheart,
2,diamond,
3,diamond,
4,diamond,
5,diamond,
6,diamond,
7,diamond,
8,diamond,
9,diamond,
10,diamond,
J,diamond,
Q,diamond,
K,diamond,
Adiamond,
2,club,
3,club,
4,club,
5,club,
6,club,
7,club,
8,club,
9,club,
10,club,
J,club,
Q,club,
K,club,
Aclub,
2,spade
3,spade
4,spade
5,spade
6,spade
7,spade
8,spade
9,spade
10,spade
J,spade
Q,spade
K,spade
Aspade
This post has been edited by capty99: 07 September 2006 - 08:24 AM

New Topic/Question
Reply




MultiQuote




|