• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Regarding 'Random' numbers..

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..

 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think Michael forgot 1st April was last week when he said "from the bottom"
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think your explanation is easier to understand than mine, Maneesh
reply
    Bookmark Topic Watch Topic
  • New Topic