• 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

Please help with unwrap, deck, shuffle cards

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Write a program called “Project_BridgeDeal” that adds the methods required for the main method shown below. The objective is to initialize the deck, shuffle the deck, deal thirteen cards to each of four players, and display the hand dealt to each player sorted by suit and rank. The names of the four players are North, East, South, and West. You may use the code in Listing 6.2 in the text if you wish.

1. These are the methods you need to add:
• public static void unwrap(int[] pack) { // Initialize the deck
• public static void shuffle(int[] pack) { // Shuffle the deck
• public static int[] deal(int[] pack, int n, int offset) { // Deal “n” cards offset from the beginning of the deck. Return the hand dealt as an array of integers.
• public static void showHand(int[] hand, String player) { // Show a player’s hand sorted by suit and rank. The name of the player is passed as a string.


Here is a sample run of the program:

North was dealt:
2 of Spades
6 of Spades
8 of Spades
2 of Hearts
3 of Hearts
8 of Hearts
10 of Hearts
6 of Diamonds
8 of Diamonds
Queen of Diamonds
King of Diamonds
4 of Clubs
5 of Clubs

East was dealt:
5 of Spades
King of Spades
6 of Hearts
9 of Hearts
Jack of Hearts
Queen of Hearts
Ace of Hearts
2 of Diamonds
4 of Diamonds
10 of Diamonds
Ace of Diamonds
9 of Clubs
Jack of Clubs

South was dealt:
3 of Spades
4 of Spades
9 of Spades
Jack of Spades
Ace of Spades
7 of Hearts
3 of Diamonds
5 of Diamonds
7 of Diamonds
Jack of Diamonds
3 of Clubs
7 of Clubs
King of Clubs

West was dealt:
7 of Spades
10 of Spades
Queen of Spades
4 of Hearts
5 of Hearts
King of Hearts
9 of Diamonds
2 of Clubs
6 of Clubs
8 of Clubs
10 of Clubs
Queen of Clubs
Ace of Clubs
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You forgot to include your code. What problems are you having with it? Please be sure to UseCodeTags when posting.
 
pots sr
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do not know how to do that?
 
pots sr
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which bit do you not know how to do? is it posting your code, using code tags (click on the link in Bear's post), asking a question or something else altogether.
Remember that the more effort you show, the more effort people are likely to put into helping you.

Edit, Ignore the above you posted the code whilst I was writing this.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Click on UseCodeTags; it's a link that explains how to post code.

Also, please check your private messages for an important administrative matter. Thanks.
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, so you have code to initialize the deck, shuffle it and print out the shuffled deck. Does it compile and run correctly?

Once you have that working look at the next part of the question which is to shuffle the deck into 4 hands - how do you think you can do that?
 
pots sr
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why deck[SUITS*i + j] = rank[i] + " of " + suit[j];

this giving me the error massage?
can not covert from string to int.
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What error message are you getting? Please post the full error message and stack trace.
 
pots sr
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it showing me the massage that " Can not convert from String to int"
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where's the stack trace?

BTW are you compiling the last code you posted, because that code doesn't give me that compiler error. If not please post the latest code.
 
Master Rancher
Posts: 4806
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pots sr wrote:why deck[SUITS*i + j] = rank[i] + " of " + suit[j];

this giving me the error massage?
can not covert from string to int.


I don't get that error when I run the code you posted. Of course, I had to fix the compilation error first - but that was on line 21. No effect on line 15. Since you've evidently changed your code since then, I recommend posting the new code, so we can discuss it. After you've changed your username, of course.
 
reply
    Bookmark Topic Watch Topic
  • New Topic