• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding 'Random' numbers..

 
kannan vinayagam Duraiswamy
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i try to develop a small card game using java (just like 'hearts' in windows OS)
in the start of the game i need to give 'random' cards to each user.
how can i implement this ...any idea..

 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add all the cards to a collection (arraylist perhaps)
then use Collections.shuffle(..) and deal 'em out (from the bottom!)
 
kannan vinayagam Duraiswamy
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"deal 'em out (from the bottom!)" - are you mean to say that
iterate the list from the bottom after shuffle...
thanks for your response...
 
Campbell Ritchie
Sheriff
Pie
Posts: 49379
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Michael forgot 1st April was last week when he said "from the bottom"
 
Maneesh Godbole
Saloon Keeper
Posts: 11066
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kannan,

In card games (read "gambling") it is "illegal" to deal from the bottom of the deck. You are liable to get kicked out of the club, barred from all casinos in Las Vegas or get killed!

It was just a phrase which Michael used in jest. He did not literally mean the last element in the ArrayList

For more on bottom dealing check this out
http://en.wikipedia.org/wiki/Bottom_dealing
 
Campbell Ritchie
Sheriff
Pie
Posts: 49379
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think your explanation is easier to understand than mine, Maneesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic