This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Incrementer Issue: Card Shuffler

 
Ranch Hand
Posts: 93
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all:

I am writing a program that can shuffle a deck of cards in different ways. I'm having some trouble in getting the program to imprint suites from one set of 13 to the next. I had it working yesterday. Now all of a sudden it will just print everything all clubs. *scratching head*.

Can anyone help me and point out where the problem is? Any help will be greatly appreciated.
Here is the code I have created below so far....



Thanks again in advance.

S.T.
 
Saloon Keeper
Posts: 10408
223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sam,

Hint: What does the very first statement within your for loop do?

Anyway, why aren't you separating responsibilities?
 
Bartender
Posts: 10771
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sam Thompson wrote:Can anyone help me and point out where the problem is? Any help will be greatly appreciated.


This won't answer your question specifically, but the fact is that StringsAreBad, so I'd strongly suggest that you think of some other way of defining your suits and values.

Oddly enough, the JLS contains an example of just what you want that uses enums. Usually it's pretty dry, but in this case it's actually better than the tutorial example IMO.

Winston
 
Is that a spider in your hair? Here, threaten it with this tiny ad:
Java Code Review and Psychology
https://coderanch.com/t/714798/java/Java-Code-Review-Psychology
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!