Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Is there a card-shuffling Java class available?

  1. #1
    Junior Member
    Join Date
    Mar 2019
    Location
    Uji-shi, Kyoto-fu, Japan
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Is there a card-shuffling Java class available?

    I'm working on a program to play through a particular variety of solitaire to determine whether or not a given shuffle of the cards can result in winning the game.

    Obviously, the first step is to create a deck (in this case, it's 2 decks for a total of 104 cards) and shuffle it.

    Since re-inventing the wheel is a mortal sin in the Church of Programming - plus the fact that I'd rather not spend the time to develop my own - I'm hoping that there
    is a Java class that someone, somewhere has already created that will accomplish this task.

    Does anyone know of such a class and where I might obtain it?

    Thanks in advance!

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,897
    Thanks
    52
    Thanked 2,335 Times in 2,291 Posts

    Default Re: Is there a card-shuffling Java class available?

    Yes, look at the Java SE API docs's Index of method names for ones starting with shuff
    https://docs.oracle.com/javase/8/docs/api/index.html
    Click on INDEX in the top blue banner, then click on S and search for shuffle for links to methods of interest
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Sep 2018
    Location
    Virginia
    Posts
    217
    My Mood
    Cool
    Thanks
    0
    Thanked 24 Times in 24 Posts

    Default Re: Is there a card-shuffling Java class available?

    Quote Originally Posted by BackInTheSaddle View Post

    Since re-inventing the wheel is a mortal sin in the Church of Programming - plus the fact that I'd rather not spend the time to develop
    my own - I'm hoping that there is a Java class that someone, somewhere has already created that will accomplish this task.
    Although a tongue-in-cheek statement, writing code that already exists is not necessarily a bad thing. It all depends on its complexity and how long it takes you to find the appropriate API. Even for those who never heard of the Fisher-Yates algorithm writing a pretty good shuffle routine would take only about 10 minutes.

    Regards,
    Jim

Similar Threads

  1. Card Class (Setting string rank value. 1 = "Ace" etc)
    By ashboi in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 9th, 2012, 03:42 PM
  2. shuffling help
    By ronimacarroni in forum Algorithms & Recursion
    Replies: 9
    Last Post: April 15th, 2012, 11:23 PM
  3. [SOLVED] array not shuffling
    By captain in forum Collections and Generics
    Replies: 2
    Last Post: February 27th, 2012, 07:32 AM
  4. Shuffling a 2D array
    By Buzzins in forum Object Oriented Programming
    Replies: 6
    Last Post: January 16th, 2012, 12:47 PM
  5. CardGuesser. Stuck on Card class HELP!
    By Stormin in forum What's Wrong With My Code?
    Replies: 9
    Last Post: August 11th, 2010, 05:41 PM