Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

- Sample output : java PJ4.Decks ******* Create 2 decks of cards ********* *****

ID: 3557066 • Letter: #

Question

- Sample output : java PJ4.Decks


******* Create 2 decks of cards *********

************************************************

Loop # 0

Before shuffle:104 cards

   [A Clubs, 2 Clubs, 3 Clubs, 4 Clubs, 5 Clubs, 6 Clubs, 7 Clubs, 8 Clubs, 9 Clubs, 10 Clubs, J Clubs, Q Clubs, K Clubs, A Diamonds, 2 Diamonds, 3 Diamonds, 4 Diamonds, 5 Diamonds, 6 Diamonds, 7 Diamonds, 8 Diamonds, 9 Diamonds, 10 Diamonds, J Diamonds, Q Diamonds, K Diamonds, A Hearts, 2 Hearts, 3 Hearts, 4 Hearts, 5 Hearts, 6 Hearts, 7 Hearts, 8 Hearts, 9 Hearts, 10 Hearts, J Hearts, Q Hearts, K Hearts, A Spades, 2 Spades, 3 Spades, 4 Spades, 5 Spades, 6 Spades, 7 Spades, 8 Spades, 9 Spades, 10 Spades, J Spades, Q Spades, K Spades, A Clubs, 2 Clubs, 3 Clubs, 4 Clubs, 5 Clubs, 6 Clubs, 7 Clubs, 8 Clubs, 9 Clubs, 10 Clubs, J Clubs, Q Clubs, K Clubs, A Diamonds, 2 Diamonds, 3 Diamonds, 4 Diamonds, 5 Diamonds, 6 Diamonds, 7 Diamonds, 8 Diamonds, 9 Diamonds, 10 Diamonds, J Diamonds, Q Diamonds, K Diamonds, A Hearts, 2 Hearts, 3 Hearts, 4 Hearts, 5 Hearts, 6 Hearts, 7 Hearts, 8 Hearts, 9 Hearts, 10 Hearts, J Hearts, Q Hearts, K Hearts, A Spades, 2 Spades, 3 Spades, 4 Spades, 5 Spades, 6 Spades, 7 Spades, 8 Spades, 9 Spades, 10 Spades, J Spades, Q Spades, K Spades]

==============================================

After shuffle:104 cards

   [9 Hearts, 7 Hearts, 6 Diamonds, K Diamonds, 8 Diamonds, 5 Hearts, 5 Diamonds, J Clubs, 2 Diamonds, 10 Spades, 4 Diamonds, A Clubs, 8 Spades, K Hearts, 9 Spades, 7 Diamonds, 6 Diamonds, K Spades, 8 Clubs, 9 Spades, 6 Clubs, 8 Clubs, 2 Hearts, A Clubs, Q Hearts, J Hearts, 2 Diamonds, Q Hearts, A Diamonds, 7 Diamonds, 5 Clubs, 6 Clubs, K Hearts, J Hearts, J Clubs, 3 Spades, 3 Diamonds, 3 Clubs, 2 Hearts, 8 Hearts, 8 Diamonds, 8 Spades, A Diamonds, 3 Clubs, 6 Hearts, 3 Hearts, 4 Spades, 4 Clubs, 8 Hearts, 2 Spades, 4 Spades, K Clubs, 5 Hearts, 5 Spades, Q Spades, K Diamonds, 5 Diamonds, 3 Diamonds, J Spades, 2 Clubs, 2 Spades, 2 Clubs, 3 Hearts, 9 Diamonds, 9 Clubs, 7 Hearts, Q Diamonds, 10 Clubs, J Diamonds, 10 Diamonds, 5 Clubs, K Spades, J Spades, 9 Hearts, K Clubs, A Hearts, 4 Hearts, 9 Clubs, 10 Spades, 6 Hearts, 10 Diamonds, 6 Spades, A Spades, J Diamonds, Q Spades, Q Clubs, A Hearts, 7 Clubs, 4 Clubs, 7 Clubs, Q Clubs, 7 Spades, A Spades, 6 Spades, 7 Spades, 4 Diamonds, 10 Hearts, 9 Diamonds, 4 Hearts, Q Diamonds, 10 Clubs, 3 Spades, 10 Hearts, 5 Spades]


Hand 0:30 cards

   [5 Spades, 10 Hearts, 3 Spades, 10 Clubs, Q Diamonds, 4 Hearts, 9 Diamonds, 10 Hearts, 4 Diamonds, 7 Spades, 6 Spades, A Spades, 7 Spades, Q Clubs, 7 Clubs, 4 Clubs, 7 Clubs, A Hearts, Q Clubs, Q Spades, J Diamonds, A Spades, 6 Spades, 10 Diamonds, 6 Hearts, 10 Spades, 9 Clubs, 4 Hearts, A Hearts, K Clubs]


Remain:74 cards

   [9 Hearts, 7 Hearts, 6 Diamonds, K Diamonds, 8 Diamonds, 5 Hearts, 5 Diamonds, J Clubs, 2 Diamonds, 10 Spades, 4 Diamonds, A Clubs, 8 Spades, K Hearts, 9 Spades, 7 Diamonds, 6 Diamonds, K Spades, 8 Clubs, 9 Spades, 6 Clubs, 8 Clubs, 2 Hearts, A Clubs, Q Hearts, J Hearts, 2 Diamonds, Q Hearts, A Diamonds, 7 Diamonds, 5 Clubs, 6 Clubs, K Hearts, J Hearts, J Clubs, 3 Spades, 3 Diamonds, 3 Clubs, 2 Hearts, 8 Hearts, 8 Diamonds, 8 Spades, A Diamonds, 3 Clubs, 6 Hearts, 3 Hearts, 4 Spades, 4 Clubs, 8 Hearts, 2 Spades, 4 Spades, K Clubs, 5 Hearts, 5 Spades, Q Spades, K Diamonds, 5 Diamonds, 3 Diamonds, J Spades, 2 Clubs, 2 Spades, 2 Clubs, 3 Hearts, 9 Diamonds, 9 Clubs, 7 Hearts, Q Diamonds, 10 Clubs, J Diamonds, 10 Diamonds, 5 Clubs, K Spades, J Spades, 9 Hearts]

==============================================

After shuffle:74 cards

   [2 Hearts, Q Hearts, 6 Clubs, 8 Diamonds, 6 Clubs, 8 Hearts, J Spades, J Spades, 2 Diamonds, 3 Diamonds, 3 Clubs, 5 Clubs, 7 Diamonds, 9 Diamonds, 2 Diamonds, 2 Clubs, 4 Spades, K Hearts, 2 Spades, 4 Clubs, Q Diamonds, 3 Diamonds, K Clubs, 7 Diamonds, 2 Clubs, 10 Diamonds, K Spades, J Clubs, 8 Diamonds, 5 Diamonds, J Diamonds, 6 Diamonds, 8 Hearts, 4 Diamonds, 5 Hearts, J Clubs, 3 Clubs, 9 Spades, 3 Hearts, 9 Hearts, 7 Hearts, A Diamonds, 7 Hearts, 2 Hearts, J Hearts, 9 Spades, A Diamonds, 8 Spades, K Hearts, K Diamonds, 8 Spades, 10 Clubs, K Diamonds, 8 Clubs, A Clubs, 10 Spades, 5 Clubs, 5 Hearts, J Hearts, 9 Clubs, Q Spades, A Clubs, 8 Clubs, 3 Spades, 9 Hearts, 6 Hearts, 2 Spades, 3 Hearts, Q Hearts, 5 Diamonds, 4 Spades, 5 Spades, K Spades, 6 Diamonds]


Hand 1:30 cards

   [6 Diamonds, K Spades, 5 Spades, 4 Spades, 5 Diamonds, Q Hearts, 3 Hearts, 2 Spades, 6 Hearts, 9 Hearts, 3 Spades, 8 Clubs, A Clubs, Q Spades, 9 Clubs, J Hearts, 5 Hearts, 5 Clubs, 10 Spades, A Clubs, 8 Clubs, K Diamonds, 10 Clubs, 8 Spades, K Diamonds, K Hearts, 8 Spades, A Diamonds, 9 Spades, J Hearts]


Remain:44 cards

   [2 Hearts, Q Hearts, 6 Clubs, 8 Diamonds, 6 Clubs, 8 Hearts, J Spades, J Spades, 2 Diamonds, 3 Diamonds, 3 Clubs, 5 Clubs, 7 Diamonds, 9 Diamonds, 2 Diamonds, 2 Clubs, 4 Spades, K Hearts, 2 Spades, 4 Clubs, Q Diamonds, 3 Diamonds, K Clubs, 7 Diamonds, 2 Clubs, 10 Diamonds, K Spades, J Clubs, 8 Diamonds, 5 Diamonds, J Diamonds, 6 Diamonds, 8 Hearts, 4 Diamonds, 5 Hearts, J Clubs, 3 Clubs, 9 Spades, 3 Hearts, 9 Hearts, 7 Hearts, A Diamonds, 7 Hearts, 2 Hearts]

==============================================

After shuffle:44 cards

   [J Spades, 3 Clubs, 7 Hearts, 5 Clubs, J Clubs, 4 Spades, A Diamonds, J Spades, 2 Spades, 7 Diamonds, 6 Diamonds, 9 Hearts, J Clubs, 3 Clubs, 2 Diamonds, 5 Diamonds, 2 Hearts, 2 Clubs, 8 Hearts, 2 Clubs, 10 Diamonds, 9 Spades, K Clubs, J Diamonds, Q Diamonds, 4 Diamonds, 5 Hearts, 4 Clubs, 3 Diamonds, 3 Diamonds, Q Hearts, 7 Hearts, 6 Clubs, 8 Diamonds, 2 Hearts, 6 Clubs, 7 Diamonds, 8 Diamonds, 9 Diamonds, K Spades, K Hearts, 2 Diamonds, 3 Hearts, 8 Hearts]


Hand 2:30 cards

   [8 Hearts, 3 Hearts, 2 Diamonds, K Hearts, K Spades, 9 Diamonds, 8 Diamonds, 7 Diamonds, 6 Clubs, 2 Hearts, 8 Diamonds, 6 Clubs, 7 Hearts, Q Hearts, 3 Diamonds, 3 Diamonds, 4 Clubs, 5 Hearts, 4 Diamonds, Q Diamonds, J Diamonds, K Clubs, 9 Spades, 10 Diamonds, 2 Clubs, 8 Hearts, 2 Clubs, 2 Hearts, 5 Diamonds, 2 Diamonds]


Remain:14 cards

   [J Spades, 3 Clubs, 7 Hearts, 5 Clubs, J Clubs, 4 Spades, A Diamonds, J Spades, 2 Spades, 7 Diamonds, 6 Diamonds, 9 Hearts, J Clubs, 3 Clubs]

==============================================

After shuffle:14 cards

   [A Diamonds, 5 Clubs, 9 Hearts, 6 Diamonds, J Clubs, J Spades, 2 Spades, 3 Clubs, J Clubs, 7 Diamonds, 7 Hearts, J Spades, 3 Clubs, 4 Spades]


Hand 3:30 cards
*** In catch block : PlayingCardException : msg : Not enough cards to deal


************************************************

Loop # 1

Before shuffle:104 cards

   [A Clubs, 2 Clubs, 3 Clubs, 4 Clubs, 5 Clubs, 6 Clubs, 7 Clubs, 8 Clubs, 9 Clubs, 10 Clubs, J Clubs, Q Clubs, K Clubs, A Diamonds, 2 Diamonds, 3 Diamonds, 4 Diamonds, 5 Diamonds, 6 Diamonds, 7 Diamonds, 8 Diamonds, 9 Diamonds, 10 Diamonds, J Diamonds, Q Diamonds, K Diamonds, A Hearts, 2 Hearts, 3 Hearts, 4 Hearts, 5 Hearts, 6 Hearts, 7 Hearts, 8 Hearts, 9 Hearts, 10 Hearts, J Hearts, Q Hearts, K Hearts, A Spades, 2 Spades, 3 Spades, 4 Spades, 5 Spades, 6 Spades, 7 Spades, 8 Spades, 9 Spades, 10 Spades, J Spades, Q Spades, K Spades, A Clubs, 2 Clubs, 3 Clubs, 4 Clubs, 5 Clubs, 6 Clubs, 7 Clubs, 8 Clubs, 9 Clubs, 10 Clubs, J Clubs, Q Clubs, K Clubs, A Diamonds, 2 Diamonds, 3 Diamonds, 4 Diamonds, 5 Diamonds, 6 Diamonds, 7 Diamonds, 8 Diamonds, 9 Diamonds, 10 Diamonds, J Diamonds, Q Diamonds, K Diamonds, A Hearts, 2 Hearts, 3 Hearts, 4 Hearts, 5 Hearts, 6 Hearts, 7 Hearts, 8 Hearts, 9 Hearts, 10 Hearts, J Hearts, Q Hearts, K Hearts, A Spades, 2 Spades, 3 Spades, 4 Spades, 5 Spades, 6 Spades, 7 Spades, 8 Spades, 9 Spades, 10 Spades, J Spades, Q Spades, K Spades]

==============================================

After shuffle:104 cards

   [2 Spades, 8 Diamonds, 7 Diamonds, 4 Diamonds, Q Hearts, A Clubs, J Spades, 9 Clubs, J Clubs, 2 Clubs, 4 Hearts, 7 Hearts, A Spades, 8 Clubs, A Diamonds, 3 Diamonds, 6 Clubs, K Diamonds, 9 Diamonds, 9 Diamonds, 6 Clubs, 7 Spades, 2 Hearts, A Clubs, 6 Hearts, 9 Clubs, K Spades, A Diamonds, 3 Diamonds, 5 Spades, K Hearts, 2 Hearts, Q Hearts, 9 Spades, 8 Spades, J Diamonds, 4 Hearts, 6 Spades, 4 Spades, Q Clubs, 3 Hearts, 3 Spades, Q Diamonds, 5 Spades, A Spades, Q Diamonds, 10 Clubs, 5 Hearts, 5 Hearts, 9 Hearts, 3 Hearts, 6 Diamonds, 2 Spades, Q Clubs, 7 Diamonds, 10 Diamonds, 2 Diamonds, 6 Diamonds, 8 Clubs, 4 Clubs, K Spades, 10 Hearts, 2 Diamonds, A Hearts, J Diamonds, 8 Hearts, 5 Clubs, A Hearts, 5 Diamonds, Q Spades, 3 Clubs, J Hearts, 3 Spades, 6 Hearts, 10 Hearts, K Diamonds, 10 Spades, 8 Hearts, J Clubs, 4 Diamonds, 10 Clubs, J Spades, 4 Clubs, 7 Clubs, 10 Spades, 5 Diamonds, 2 Clubs, 6 Spades, J Hearts, 8 Diamonds, K Clubs, 3 Clubs, 7 Spades, 9 Spades, 7 Clubs, Q Spades, K Hearts, 5 Clubs, 9 Hearts, 10 Diamonds, K Clubs, 8 Spades, 7 Hearts, 4 Spades]


Hand 0:30 cards

   [4 Spades, 7 Hearts, 8 Spades, K Clubs, 10 Diamonds, 9 Hearts, 5 Clubs, K Hearts, Q Spades, 7 Clubs, 9 Spades, 7 Spades, 3 Clubs, K Clubs, 8 Diamonds, J Hearts, 6 Spades, 2 Clubs, 5 Diamonds, 10 Spades, 7 Clubs, 4 Clubs, J Spades, 10 Clubs, 4 Diamonds, J Clubs, 8 Hearts, 10 Spades, K Diamonds, 10 Hearts]


Remain:74 cards

   [2 Spades, 8 Diamonds, 7 Diamonds, 4 Diamonds, Q Hearts, A Clubs, J Spades, 9 Clubs, J Clubs, 2 Clubs, 4 Hearts, 7 Hearts, A Spades, 8 Clubs, A Diamonds, 3 Diamonds, 6 Clubs, K Diamonds, 9 Diamonds, 9 Diamonds, 6 Clubs, 7 Spades, 2 Hearts, A Clubs, 6 Hearts, 9 Clubs, K Spades, A Diamonds, 3 Diamonds, 5 Spades, K Hearts, 2 Hearts, Q Hearts, 9 Spades, 8 Spades, J Diamonds, 4 Hearts, 6 Spades, 4 Spades, Q Clubs, 3 Hearts, 3 Spades, Q Diamonds, 5 Spades, A Spades, Q Diamonds, 10 Clubs, 5 Hearts, 5 Hearts, 9 Hearts, 3 Hearts, 6 Diamonds, 2 Spades, Q Clubs, 7 Diamonds, 10 Diamonds, 2 Diamonds, 6 Diamonds, 8 Clubs, 4 Clubs, K Spades, 10 Hearts, 2 Diamonds, A Hearts, J Diamonds, 8 Hearts, 5 Clubs, A Hearts, 5 Diamonds, Q Spades, 3 Clubs, J Hearts, 3 Spades, 6 Hearts]

==============================================

After shuffle:74 cards

   [A Hearts, A Spades, 7 Spades, 6 Spades, 5 Diamonds, 8 Clubs, 5 Spades, 10 Diamonds, 7 Diamonds, Q Clubs, 3 Hearts, 6 Diamonds, 3 Diamonds, Q Clubs, 9 Clubs, 8 Diamonds, Q Hearts, K Spades, 2 Hearts, 6 Hearts, 3 Hearts, 8 Hearts, A Hearts, 3 Spades, K Diamonds, 10 Hearts, 7 Diamonds, 5 Spades, A Diamonds, 2 Clubs, A Clubs, A Spades, 5 Hearts, 2 Spades, 8 Spades, 2 Spades, J Spades, Q Hearts, 5 Clubs, 3 Spades, 3 Diamonds, 2 Hearts, A Diamonds, J Diamonds, 9 Hearts, 4 Hearts, J Diamonds, 4 Hearts, Q Diamonds, K Spades, 9 Spades, K Hearts, 6 Clubs, J Clubs, 4 Clubs, 9 Diamonds, 4 Spades, 2 Diamonds, 10 Clubs, 8 Clubs, 9 Diamonds, Q Diamonds, 6 Diamonds, 2 Diamonds, Q Spades, 9 Clubs, J Hearts, 6 Hearts, 7 Hearts, 3 Clubs, 6 Clubs, 4 Diamonds, 5 Hearts, A Clubs]


Hand 1:30 cards

   [A Clubs, 5 Hearts, 4 Diamonds, 6 Clubs, 3 Clubs, 7 Hearts, 6 Hearts, J Hearts, 9 Clubs, Q Spades, 2 Diamonds, 6 Diamonds, Q Diamonds, 9 Diamonds, 8 Clubs, 10 Clubs, 2 Diamonds, 4 Spades, 9 Diamonds, 4 Clubs, J Clubs, 6 Clubs, K Hearts, 9 Spades, K Spades, Q Diamonds, 4 Hearts, J Diamonds, 4 Hearts, 9 Hearts]


Remain:44 cards

   [A Hearts, A Spades, 7 Spades, 6 Spades, 5 Diamonds, 8 Clubs, 5 Spades, 10 Diamonds, 7 Diamonds, Q Clubs, 3 Hearts, 6 Diamonds, 3 Diamonds, Q Clubs, 9 Clubs, 8 Diamonds, Q Hearts, K Spades, 2 Hearts, 6 Hearts, 3 Hearts, 8 Hearts, A Hearts, 3 Spades, K Diamonds, 10 Hearts, 7 Diamonds, 5 Spades, A Diamonds, 2 Clubs, A Clubs, A Spades, 5 Hearts, 2 Spades, 8 Spades, 2 Spades, J Spades, Q Hearts, 5 Clubs, 3 Spades, 3 Diamonds, 2 Hearts, A Diamonds, J Diamonds]

==============================================

After shuffle:44 cards

   [3 Diamonds, Q Clubs, 5 Spades, 7 Diamonds, 5 Hearts, Q Hearts, 5 Diamonds, K Spades, 2 Hearts, A Spades, 10 Diamonds, Q Hearts, 3 Hearts, A Clubs, 3 Diamonds, 3 Spades, A Hearts, 2 Hearts, 6 Diamonds, A Diamonds, 10 Hearts, J Diamonds, 6 Spades, 7 Spades, 8 Clubs, 7 Diamonds, 8 Diamonds, K Diamonds, J Spades, 8 Spades, 3 Spades, A Hearts, 5 Clubs, A Spades, 3 Hearts, 2 Spades, 2 Spades, 2 Clubs, A Diamonds, 5 Spades, 8 Hearts, Q Clubs, 6 Hearts, 9 Clubs]


Hand 2:30 cards

   [9 Clubs, 6 Hearts, Q Clubs, 8 Hearts, 5 Spades, A Diamonds, 2 Clubs, 2 Spades, 2 Spades, 3 Hearts, A Spades, 5 Clubs, A Hearts, 3 Spades, 8 Spades, J Spades, K Diamonds, 8 Diamonds, 7 Diamonds, 8 Clubs, 7 Spades, 6 Spades, J Diamonds, 10 Hearts, A Diamonds, 6 Diamonds, 2 Hearts, A Hearts, 3 Spades, 3 Diamonds]


Remain:14 cards

   [3 Diamonds, Q Clubs, 5 Spades, 7 Diamonds, 5 Hearts, Q Hearts, 5 Diamonds, K Spades, 2 Hearts, A Spades, 10 Diamonds, Q Hearts, 3 Hearts, A Clubs]

==============================================

After shuffle:14 cards

   [5 Diamonds, A Clubs, 5 Hearts, 10 Diamonds, Q Hearts, Q Clubs, A Spades, K Spades, 3 Diamonds, 2 Hearts, Q Hearts, 7 Diamonds, 5 Spades, 3 Hearts]


Hand 3:30 cards
*** In catch block : PlayingCardException : msg : Not enough cards to deal


******************************************************************************************


- Sample output : java PJ4.MyPokerGame

[A Spades, 10 Spades, Q Spades, J Spades, K Spades]
Royal Flush!
-----------------------------------
[9 Spades, 10 Spades, Q Spades, J Spades, K Spades]
Straight Flush!
-----------------------------------
[9 Spades, 10 Spades, Q Spades, J Spades, 8 Diamonds]
Straight!
-----------------------------------
[9 Spades, 10 Spades, Q Spades, J Spades, 5 Spades]
Flush!
-----------------------------------
[8 Spades, 8 Clubs, Q Spades, 8 Diamonds, 8 Hearts]
Four of a Kind!
-----------------------------------
[8 Spades, 8 Clubs, Q Spades, 8 Diamonds, J Spades]
Three of a Kind!
-----------------------------------
[8 Spades, 8 Clubs, J Diamonds, 8 Diamonds, J Spades]
Full House!
-----------------------------------
[8 Spades, 9 Diamonds, J Diamonds, 8 Diamonds, J Spades]
Two Pairs!
-----------------------------------
[3 Diamonds, 9 Diamonds, J Diamonds, 8 Diamonds, J Spades]
Royal Pair!
-----------------------------------
[3 Diamonds, 9 Diamonds, 3 Spades, 8 Diamonds, J Spades]
Sorry, you lost!
-----------------------------------


******************************************************************************************

$ java TestMyPokerGame 1000

Payout Table Multiplier
=======================================
Royal Flush | 250
Straight Flush | 50
Four of a Kind | 25
Full House | 9
Flush | 6
Straight | 5
Three of a Kind | 3
Two Pairs | 2
Royal Pair | 1

-----------------------------------
Balance:$1000
Enter bet:500
Hand:[2 Diamonds, K Spades, 6 Clubs, 9 Clubs, 4 Spades]
Enter positions of cards to keep (e.g. 1 4 5 ):2 3
Hand:[10 Diamonds, K Spades, 6 Clubs, 6 Diamonds, 9 Hearts]
Sorry, you lost!

Your balance:$500, one more game (y or n)?y

Want to see payout table (y or n)n
-----------------------------------
Balance:$500
Enter bet:600
insufficient fund!
Enter bet:500
Hand:[A Diamonds, 9 Hearts, 6 Clubs, K Hearts, A Hearts]
Enter positions of cards to keep (e.g. 1 4 5 ):1 5
Hand:[A Diamonds, 4 Diamonds, 9 Diamonds, J Spades, A Hearts]
Royal Pair!

Your balance:$500, one more game (y or n)?y

Want to see payout table (y or n)y

Payout Table Multiplier
=======================================
Royal Flush | 250
Straight Flush | 50
Four of a Kind | 25
Full House | 9
Flush | 6
Straight | 5
Three of a Kind | 3
Two Pairs | 2
Royal Pair | 1

-----------------------------------
Balance:$500
Enter bet:500
Hand:[8 Clubs, 4 Spades, J Hearts, 9 Clubs, 10 Diamonds]
Enter positions of cards to keep (e.g. 1 4 5 ):1 2 3 4 5
Hand:[8 Clubs, 4 Spades, J Hearts, 9 Clubs, 10 Diamonds]
Sorry, you lost!

Your balance is 0
Bye!


  

package PJ4;
import java.util.*;

/*
* Ref: http://en.wikipedia.org/wiki/Video_poker
* http://www.google.com/ig/directory?type=gadgets&url=www.labpixies.com/campaigns/videopoker/videopoker.xml
*
*
* Short Description and Poker rules:
*
* Video poker is also known as draw poker.
* The dealer uses a 52-card deck, which is played fresh after each currentHand.
* The player is dealt one five-card poker currentHand.
* After the first draw, which is automatic, you may hold any of the cards and draw
* again to replace the cards that you haven't chosen to hold.
* Your cards are compared to a table of winning combinations.
* The object is to get the best possible combination so that you earn the highest
* payout on the bet you placed.
*
* Winning Combinations
*
* 1. Jacks or Better: a pair pays out only if the cards in the pair are Jacks,
*    Queens, Kings, or Aces. Lower pairs do not pay out.
* 2. Two Pair: two sets of pairs of the same card denomination.
* 3. Three of a Kind: three cards of the same denomination.
* 4. Straight: five consecutive denomination cards of different suit.
* 5. Flush: five non-consecutive denomination cards of the same suit.
* 6. Full House: a set of three cards of the same denomination plus
*    a set of two cards of the same denomination.
* 7. Four of a kind: four cards of the same denomination.
* 8. Straight Flush: five consecutive denomination cards of the same suit.
* 9. Royal Flush: five consecutive denomination cards of the same suit,
*    starting from 10 and ending with an ace
*
*/


/* This is the main poker game class.
* It uses Decks and Card objects to implement poker game.
* Please do not modify any data fields or defined methods
* You may add new data fields and methods
* Note: You must implement defined methods
*/

public class MyPokerGame {

// default constant values
private static final int startingBalance=100;
private static final int numberOfCards=5;

// default constant payout value and currentHand types
private static final int[] multipliers={1,2,3,5,6,9,25,50,250};
private static final String[] goodHandTypes={
   "Royal Pair" , "Two Pairs" , "Three of a Kind", "Straight", "Flush   ",
   "Full House", "Four of a Kind", "Straight Flush", "Royal Flush" };

// must use only one deck
private static final Decks Decks(1);

// holding current poker 5-card hand, balance, bet
private List currentHand;
private int balance;
private int bet;

/** default constructor, set balance = startingBalance */
public MyPokerGame()
{
   this(startingBalance);
}

/** constructor, set given balance */
public MyPokerGame(int balance)
{
   this.balance= balance;
}

/** This display the payout table based on multipliers and goodHandTypes arrays */
private void showPayoutTable()
{
   System.out.println(" ");
   System.out.println("Payout Table    Multiplier ");
   System.out.println("=======================================");
   int size = multipliers.length;
   for (int i=size-1; i >= 0; i--) {
       System.out.println(goodHandTypes[i]+" | "+multipliers[i]);
   }
   System.out.println(" ");
}

/** Check current currentHand using multipliers and goodHandTypes arrays
* Must print yourHandType (default is "Sorry, you lost") at the end of function.
* This can be checked by testCheckHands() and main() method.
*/
private void checkHands()
{
// implement this method!
}


/*************************************************
* add new private methods here ....
*
*************************************************/


public void play()
{
/** The main algorithm for single player poker game
*
* Steps:
*        showPayoutTable()
*
*        ++  
*        show balance, get bet
*       verify bet value, update balance
*       reset deck, shuffle deck,
*       deal cards and display cards
*       ask for position of cards to keep
* get positions in one input line
*       update cards
*       check hands, display proper messages
*       update balance if there is a payout
*       if balance = O:
*           end of program
*       else
*           ask if the player wants to play a new game
*           if the answer is "no" : end of program
*           else : showPayoutTable() if user wants to see it
*           goto ++
*/

// implement this method!
}


/** Do not modify this. It is used to test checkHands() method
* checkHands() should print your current hand type
*/
public void testCheckHands()
{
   try {
       currentHand = new ArrayList();

       // set Royal Flush
       currentHand.add(new Card(1,3));
       currentHand.add(new Card(10,3));
       currentHand.add(new Card(12,3));
       currentHand.add(new Card(11,3));
       currentHand.add(new Card(13,3));
       System.out.println(currentHand);
       checkHands();
       System.out.println("-----------------------------------");

       // set Straight Flush
       currentHand.set(0,new Card(9,3));
       System.out.println(currentHand);
       checkHands();
       System.out.println("-----------------------------------");

       // set Straight
       currentHand.set(4, new Card(8,1));
       System.out.println(currentHand);
       checkHands();
       System.out.println("-----------------------------------");

       // set Flush
       currentHand.set(4, new Card(5,3));
       System.out.println(currentHand);
       checkHands();
       System.out.println("-----------------------------------");

       // "Royal Pair" , "Two Pairs" , "Three of a Kind", "Straight", "Flush   ",
      // "Full House", "Four of a Kind", "Straight Flush", "Royal Flush" };

       // set Four of a Kind
       currentHand.clear();
       currentHand.add(new Card(8,3));
       currentHand.add(new Card(8,0));
       currentHand.add(new Card(12,3));
       currentHand.add(new Card(8,1));
       currentHand.add(new Card(8,2));
       System.out.println(currentHand);
       checkHands();
       System.out.println("-----------------------------------");

       // set Three of a Kind
       currentHand.set(4, new Card(11,3));
       System.out.println(currentHand);
       checkHands();
       System.out.println("-----------------------------------");

       // set Full House
       currentHand.set(2, new Card(11,1));
       System.out.println(currentHand);
       checkHands();
       System.out.println("-----------------------------------");

       // set Two Pairs
       currentHand.set(1, new Card(9,1));
       System.out.println(currentHand);
       checkHands();
       System.out.println("-----------------------------------");

       // set Royal Pair
       currentHand.set(0, new Card(3,1));
       System.out.println(currentHand);
       checkHands();
       System.out.println("-----------------------------------");

       // non Royal Pair
       currentHand.set(2, new Card(3,3));
       System.out.println(currentHand);
       checkHands();
       System.out.println("-----------------------------------");
   }
   catch (Exception e)
   {
       System.out.println(e.getMessage());
   }
}

/* Quick testCheckHands() */
public static void main(String args[])
{
   MyPokerGame mypokergame = new MyPokerGame();
   mypokergame.testCheckHands();
}
}

package PJ4;

import java.util.*;

/** class PlayingCardException: It is used for errors related to Card and Deck objects
* Do not modify this class!
*/
class PlayingCardException extends Exception {

/* Constructor to create a PlayingCardException object */
PlayingCardException (){
       super ();
}

PlayingCardException ( String reason ){
       super ( reason );
}
}


/** class Card : for creating playing card objects
* it is an immutable class.
* Rank - valid values are 1 to 13
* Suit - valid values are 0 to 3
* Do not modify this class!
*/
class Card {
  
/* constant suits and ranks */
static final String[] Suit = {"Clubs", "Diamonds", "Hearts", "Spades" };
static final String[] Rank = {"","A","2","3","4","5","6","7","8","9","10","J","Q","K"};

/* Data field of a card: rank and suit */
private int cardRank; /* values: 1-13 (see Rank[] above) */
private int cardSuit; /* values: 0-3 (see Suit[] above) */

/* Constructor to create a card */
/* throw PlayingCardException if rank or suit is invalid */
public Card(int rank, int suit) throws PlayingCardException {
   if ((rank < 1) || (rank > 13))
       throw new PlayingCardException("Invalid rank:"+rank);
   else
   cardRank = rank;
   if ((suit < 0) || (suit > 3))
       throw new PlayingCardException("Invalid suit:"+suit);
   else
   cardSuit = suit;
}

/* Accessor and toString */
/* You may impelemnt equals(), but it will not be used */
public int getRank() { return cardRank; }
public int getSuit() { return cardSuit; }
public String toString() { return Rank[cardRank] + " " + Suit[cardSuit]; }

  
/* Few quick tests here */
public static void main(String args[])
{
   try {
   Card c1 = new Card(1,3); // A Spades
   System.out.println(c1);
   c1 = new Card(10,0);   // 10 Clubs
   System.out.println(c1);
   c1 = new Card(10,5); // generate exception here
   }
   catch (PlayingCardException e)
   {
   System.out.println("PlayingCardException: "+e.getMessage());
   }
}
}


/** class Decks represents : n decks of 52 playing cards
* Use class Card to construct n * 52 playing cards!
*
* Do not add new data fields!
* Do not modify any methods
* You may add private methods
*/

class Decks {

/* this is used to keep track of original n*52 cards */
private List originalDecks;   

/* this starts with n*52 cards deck from original deck */
/* it is used to keep track of remaining cards to deal */
/* see reset(): it resets dealDecks to a full deck */
private List dealDecks;

/* number of decks in this object */
private int numberDecks;


/**
* Constructor: Creates default one deck of 52 playing cards in originalDecks and
*        copy them to dealDecks.
* initialize numberDecks=n
* Note: You need to catch PlayingCardException from Card constructor
*   Use ArrayList for both originalDecks & dealDecks
*/
public Decks()
{
// implement this method!
}


/**
* Constructor: Creates n decks (52 cards each deck) of playing cards in
* originalDecks and copy them to dealDecks.
* initialize numberDecks=n
* Note: You need to catch PlayingCardException from Card constructor
*   Use ArrayList for both originalDecks & dealDecks
*/
public Decks(int n)
{
// implement this method!
}


/**
* Task: Shuffles cards in deal deck.
* Hint: Look at java.util.Collections
*/
public void shuffle()
{
// implement this method!
}

/**
* Task: Deals cards from the deal deck.
*
* @param numberCards number of cards to deal
* @return a list containing cards that were dealt
* @throw PlayingCardException if numberCard > number of remaining cards
*
* Note: You need to create ArrayList to stored dealt cards
* and should removed dealt cards from dealDecks
*
*/
public List deal(int numberCards) throws PlayingCardException
{
// implement this method!
return null;
}

/**
* Task: Resets deal deck by getting all cards from the original deck.
*/
public void reset()
{
// implement this method!
}

/**
* Task: Return number of remaining cards in deal deck.
*/
public int remain()
{
   return dealDecks.size();
}

/**
* Task: Returns a string representing cards in the deal deck
*/
public String toString()
{
   return ""+dealDecks;
}


/* Quick test */
/* */
/* Do not modify these tests */
/* Generate 2 decks of cards */
/* Loop 2 times: */
/* Deal 30 cards for 4 times */
/* Expect exception last time */
/* reset() */

public static void main(String args[]) {

System.out.println("******* Create 2 decks of cards ********* ");
Decks decks = new Decks(2);

   for (int j=0; j < 2; j++)
   {
   System.out.println(" ************************************************ ");
   System.out.println("Loop # " + j + " ");
       System.out.println("Before shuffle:"+decks.remain()+" cards");
       System.out.println(" "+decks);
   System.out.println(" ============================================== ");

int numHands = 4;
int cardsPerHand = 30;

   for (int i=0; i < numHands; i++)
      {
           decks.shuffle();
       System.out.println("After shuffle:"+decks.remain()+" cards");
       System.out.println(" "+decks);
           try {
       System.out.println(" Hand "+i+":"+cardsPerHand+" cards");
       System.out.println(" "+decks.deal(cardsPerHand));
       System.out.println(" Remain:"+decks.remain()+" cards");
       System.out.println(" "+decks);
   System.out.println(" ============================================== ");
           }
           catch (PlayingCardException e)
           {
          System.out.println("*** In catch block : PlayingCardException : msg : "+e.getMessage());
           }
       }


       decks.reset();
   }
}

}

Explanation / Answer


import java.util.Random;

public class Card {
private String face;
private String suit;
//two-argument constructor initializes Cards face and suit
public Card(String face, String suit) {
super();
this.face = face;
this.suit = suit;
}
//getter method to return the face value
public String getFace() {
return face;
}
//setter method to initialize the face
public void setFace(String face) {
this.face = face;
}
//getter method to return the suit value
public String getSuit() {
return suit;
}
//setter method to initialize the suit
public void setSuit(String suit) {
this.suit = suit;
}
//return String representation of Card object
public String toString() {
return face + " of " + suit;
}
}//end of class


public class Deck {
private final String faces[] = {"Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"};
private final String suits[]={"Hearts","Diamonds","Clubs","Spades"};
private Card deck[];
private final int TOTAL_CARDS=52;
private Random randNum;
//no-argument constructor fills the deck of cards
public Deck(){
deck = new Card[TOTAL_CARDS];
randNum = new Random();
for(int i=0;i<deck.length;i++){
deck[i] = new Card(faces[i%13],suits[i/13]);
}
}
  
//shuffles the deck
public void shuffle(){
for(inti=0;i<deck.length;i++){
int j = randNum.nextInt(TOTAL_CARDS);
Card c = deck[i];
deck[i] = deck[j];
deck[j] = c;
}
}

//returns the individual card in the deck
public Card getCard(int index){
return deck[index];
}
}//end of class

public class Player {
public final static int MAX_CARD = 5;
private Card cards[];
//constructor initializes 5 cards in each hand
public Player() {
cards = new Card[MAX_CARD];
}
//returns all the cards in hand
public Card[] getCards() {
return cards;
}
//get the cards at a particular position
public Card getCardAtIndex(int index) {
if (index >= 0 && index < MAX_CARD)
return cards[index];
else
return null;
}
//sets the card at particular position
public void setCardAtIndex(Card c, int index) {
if(index >= 0 && index < MAX_CARD)
cards[index] = c;
}
//counts number of matched pair
public int countPair() {
int count = 0;
for (int i = 0; i < cards.length; i++) {
for (int j = i + 1; j < cards.length; j++) {
if (cards[i].getFace().equals(cards[j].getFace())){
count++;
}
}
}
return count;
}

//checks if it is a flush or not i.e all five cards of same suit
public boolean isFlush() {
int count = 0;
for (int i = 0; i < cards.length; i++) {
for (int j = i + 1; j < cards.length; j++) {
if (cards[i].getSuit().equals(cards[j].getSuit())) {
count++;
}
}
}
if(count == 5)
return true;
else
return false;
}
}

public class Game {
private Player[] players;
private Deck deck;
//constructor initializes the deck and cards
public Game() {
deck = new Deck();
players = new Player[4];
players[0] = new Player();
players[1] = new Player();
players[2] = new Player();
players[3] = new Player();
deck.shuffle();
}
//deals the card to each player
public void dealCards() {
int count = 0;
for (int i = 0; i < players[0].getCards().length; i++) {
for (int j = 0; j < players.length; j++) {
players[j].setCardAtIndex(deck.getCard(count++), i);
}
}
}
//simulates the game and shows the result
public void showCards() {
for (int i = 0; i < players.length; i++) {
System.out.print("Player " + (i + 1) + ": ");
for (int j = 0; j < players[0].getCards().length; j++) {
System.out.print("{" + players[i].getCardAtIndex(j).toString()+"} ");
}
if(players[i].countPair()> 0)
System.out.print(" PAIR(S):" + players[i].countPair()+ "! ");
if(players[i].isFlush())
System.out.print("FLUSH!! ");
System.out.println(" ------------------------------------");
}
}
}//end of class

public class GameApp {
public static void main(String[] args) {
Game game = new Game();
game.dealCards();
game.showCards();
}//end of main
}//end of class

Another Code:


import java.util.ArrayList;
import java.util.Collections;

public class Deck {

private final int NUM_DECKS = 1;
private final int TOTAL_NUM_CARDS =
Suits.NUM_SUITS * Ranks.NUM_RANKS * NUM_DECKS;

/* the cards in the Deck */
private ArrayList<Card> theCards =
new ArrayList<Card>();

/* the index into the ArrayList for the next card to deal */
private int curCard;


public Deck (){
initDeck();
curCard = 0;
}

/**
* initializes a new deck helper function
*/
private void initDeck(){
Card tmp;
for(int k=0; k<NUM_DECKS; k++ ){
for( Suits s : Suits.values() ){
for( Ranks r : Ranks.values() ){
tmp = new Card( r, s );
theCards.add( tmp );
}
}
}
}

/**
* Deals the next card from the deck
*
* @return   the next card off the deck
*/
public Card dealCard(){
Card res = theCards.get( curCard );
curCard = curCard + 1;
return res;
}

public void shuffle(){
Collections.shuffle( theCards );
curCard = 0;
}

/**
* Print out the contents of the deck
*/
public void printDeck(){
for( int i=0; i<TOTAL_NUM_CARDS; i++ ){
System.out.print( theCards.get( i ).getShortName() + " " );
if( ( i + 1 ) % Ranks.NUM_RANKS == 0 ){
System.out.println();
}
}
System.out.println();
}


/**
* main method for a test driver that should test all the methods
* in the class
*
* @param args command line arguments
*/
public static void main( String args[] ){
   Deck d = new Deck();
   d.printDeck();
   d.shuffle();
   d.printDeck();
}

} // Deck

public enum Ranks {

DEUCE( " 2", 2 ),
THREE( " 3", 3 ),
FOUR ( " 4", 4 ),
FIVE ( " 5", 5 ),
SIX ( " 6", 6 ),
SEVEN( " 7", 7 ),
EIGHT( " 8", 8 ),
NINE ( " 9", 9 ),
TEN ( "10", 10 ),
JACK ( " J", 11 ),
QUEEN( " Q", 12 ),
KING ( " K", 13 ),
ACE ( " A", 14 );

/**
* a constant for the total number of ranks
*/
public static final int NUM_RANKS = 13;
private final String shortName;
private final int value;

/**
* initialize the ranks enums,
*
* @param n short name for the ranks
* @param v the value of the rank
*/
Ranks( String n, int v ){
shortName = n;
   value = v;
}

/**
* accessor for the name
*
* @return a string with the short name for this ranks
*/
public String getShortName(){
return shortName;
}

/**
* accessor for the value
*
* @return an int for the value of the rank
*/
public int getValue(){
return value;
}
}

public enum Suits {
   CLUBS ( 'C' ),
   DIAMONDS ( 'D' ) ,
   HEARTS ( 'H' ),
   SPADES ( 'S' );

/**
* a constant for the total number of suits
*/
public static final int NUM_SUITS = 4;
private final char shortName;

/**
* initialize the suit enums,
*
* @param n short name for the suit
*/
Suits( char n ){
   shortName = n;
}

/**
* accessor for the name
*
* @return a char with the short name for this suit
*/
public char getShortName(){
   return shortName;
}
}

public class Human {

private PokerHand myCards;
private static Scanner in = new Scanner( System.in );

/**
* Initialize a human player for 2-card poker
*/
public Human (){
   myCards = new PokerHand();
}

/**
* Asks the player if they want to stand. You should prompt the
* player with a suitable message, and then read the players response
* from standard input.
*
* @returns a boolean value specifying if the human wants to stand
*/
public boolean stand(){
   boolean res = true;
   String answer;
   char c;

   do{
   System.out.print("Do you want to stand (y/n)? ");
   answer = in.nextLine();
   answer = answer.toLowerCase();
   c = answer.charAt(0);
   }while( c != 'y' && c != 'n' );

   if ( c == 'y' ){
   res = true;
   } else {
   res = false;
   }
   return res;
}

/**
* adds a card to the human's hand
*
* @param c the card to add
*/
public void addCard(Card c){
   myCards.addCard(c);
}

/**
* prints the hand in some "nice" format
*/
public void printHand(){
   myCards.printHand();
   System.out.println( "Total:" + value() + " " );
}

/**
* clears out all the cards for the human
*/
public void newHand(){
   myCards = new PokerHand();
}


public int value() {
   return myCards.value();
}

  
public int compareTo( Computer d ){
/*
   int res;

   if( myCards.value() > d.value() ){
   res = 1;
   } else if( myCards.value() == d.value() ){
   res = 0;
   } else {
   res = -1;
   }
   return res;
*/
   return myCards.value() - d.value();
}

/**
* main method for a test driver that should test all the methods
* in the class
*
* @param args command line arguments
*/
public static void main( String args[] ){
}
}


public class Computer {

private PokerHand myCards;
private static final int BETTER_THAN_HALF_WIN_VALUE =
       ( Ranks.QUEEN.getValue() ) * 14 +
       ( Ranks.JACK.getValue() );

/**
* Initalize a computer player for 2-card poker
*/
public Computer (){
   myCards = new PokerHand();
}

public boolean stand(){
   return ( myCards.value() >= BETTER_THAN_HALF_WIN_VALUE );
}

/**
* adds a card to the computer's hand
*
* @param c the card to add
*/
public void addCard(Card c){
   myCards.addCard(c);
}

/**
* prints the hand in some "nice" format
*/
public void printHand(){
   myCards.printHand();
   System.out.println( "Total:" + value() + " " );
}

/**
* clears out all the cards for the computer
*/
public void newHand(){
   myCards = new PokerHand();
}

  
public int value() {
   return myCards.value();
}

/**
* main method for a test driver that should test all the methods
* in the class
*
* @param args command line arguments
*/
public static void main( String args[] ){
}
}

public class Card {

private Ranks rank;
private Suits suit;

/**
* Create a spesific card
*
* @param r   the Rank of the card to create
* @param s   the Suit of the card to create
*/
public Card ( Ranks r, Suits s ){
rank = r;
suit = s;
}

/**
* return the numerical value of the card
*
* @return the value of the rank of the card
*/
public int value(){
return rank.getValue();
}

/**
* accessor for the rank
*
* @return the Rank of the card
*/
public Ranks getRank(){
return rank;
}

/**
* accessor for the suit
*
* @return the Suit of the card
*/
public Suits getSuit(){
return suit;
}

/**
* returns a long name for the card, ie "THREE of CLUBS"
*
* @return the long name of the card
*/
public String toString(){
return rank + " of " + suit;
}

/**
* returns a short, three char, name for the card, ie
* " 3C", "10S" or " QH"
*
* @return the short name of the card
*/
public String getShortName(){
String res;

   res = rank.getShortName() + suit.getShortName();

return res;
}

/**
* main method for a test driver that should test all the methods
* in the class
*
* @param args   command line arguments
*/
public static void main( String args[] ){
}

} // Card

public class PokerHand{

private Card theCards[];
private int numCards;

/**
* Initialize an empty poker hand
*/
public PokerHand (){
   theCards = new Card[3];
   numCards = 0;
}

/**
* returns a numerical value to represent the hand, this value
* will make sure that if a.value>b.value then a is a better hand
* than b
*
* @return   the int value of the hand
*/
public int value(){
   int total = 0;
   int mod = 0;

   if( theCards[0].getRank() == theCards[1].getRank() ){
   mod = 1000;
   } else if( theCards[0].getSuit() == theCards[1].getSuit() ){
   mod = 500;
   }

   if( theCards[0].value() > theCards[1].value() ){
   total = mod + theCards[0].value() * 14 + theCards[1].value();
   } else {
   total = mod + theCards[1].value() * 14 + theCards[0].value();
   }

   return total;
}

/**
* adds a card to the hand
*
* @param   c   the card to add to hand
*/
public void addCard( Card c ){
   theCards[numCards] = c;
   numCards++;
}

/**
* Pretty print the hand
*/
public void printHand(){
/*
   ArrayList<Card> hand = new ArrayList<Card>( theCards );
   PrintHand.printHand( hand, numCards );
   PrintHand.printHand( theCards, numCards );
*/
   for (int i=0; i< numCards-1; i++){
   System.out.print( " " );
   }
   System.out.println( " --------" );
   for (int i=numCards-1; i>= 0; i--){
   for (int j=0; j < i-1; j++){
       System.out.print( " " );
   }
   if ( i != 0 ){
       System.out.print( " ----" );
   }
   System.out.print( "|" + theCards[i].getShortName() );
   for (int j=0; j < numCards-i-1; j++){
System.out.print( " | " );
}
   System.out.println( " |" );
   }
}

/**
* returns an "ugly" look at the cards in the hand
*
* @returns   a string containing all the cards in the hand
*/
public String toString(){
   String res = "";
   for (int i=0; i<numCards; i++ ){
   res = res + theCards[i] + " ";
   }
   return res;
}

} //PokerHand


public class Poker {

/**
* a boolean toggle that tells the order of making the stand/fold
* decision. This flips after each hand
*/
private static boolean playerGoesFirst = true;

/**
* Plays a single hand of poker
*
* @param person   The human player
* @param comp   The computer player
* @param d   The deck
* @return An int telling if the user lost/tied/won (neg/0/pos)
*/
public static int playHand( Human person, Computer comp, Deck d ){
   boolean playingHand = false;
   boolean personStand = true, dealerStand = true;
   int playerWon;

   System.out.println( "== Dealing Cards " );
   //give initial cards
   for (int j=0; j<2; j++ ){
   person.addCard( d.dealCard() );
   comp.addCard( d.dealCard() );
   }

   System.out.println( "============== Your Cards ========" );
   person.printHand();

   // ask both players if they want to stand
   if( playerGoesFirst ){
   personStand = person.stand();
   }

   if( personStand ){
   dealerStand = comp.stand();
   if( dealerStand ){
       System.out.println( "Computer Stands" );
   } else {
       System.out.println( "Computer Folds" );
   }
   }

   if( !playerGoesFirst && dealerStand){
   personStand = person.stand();
   }

   System.out.println( "============== House Cards ========" );
   comp.printHand();

   playerGoesFirst = !playerGoesFirst;
   if( personStand && dealerStand ){
   //check player win vs. computer
   playerWon = person.compareTo( comp );
   } else if( personStand ){
   playerWon = 1;   // player won by default
   } else {
   playerWon = -1;   // House won by default
   }

   // have everyone throw in their cards
   person.newHand();
   comp.newHand();

   return playerWon;
}

/**
* main method -- plays multiple hands of poker, after each hand
* ask the user if they want to play again. We also keep trak of
* the number of games played/won by the user and print the results
* at the end.
*
* @param args command line arguments
*/
public static void main( String args[] ){
   Scanner in = new Scanner( System.in );
   String again;
   char c;
   int playerWon;
   int numGames = 0;
   int numWon = 0;
   int numTie = 0;

   Deck theDeck = new Deck();
   Computer theComputer = new Computer();
   Human theHuman = new Human();

   do {
   numGames = numGames + 1;

   System.out.println();
   System.out.println( "##########################################" );
   System.out.println( "########## NEW HAND ###########" );
   System.out.println( "##########################################" );
   System.out.println( " == Shuffling" );
   theDeck.shuffle();

   playerWon = playHand( theHuman, theComputer, theDeck );
   if( playerWon > 0 ){
       System.out.println( " **** Human Won **** " );
       numWon = numWon + 1;
   } else if( playerWon == 0 ){
       System.out.println( " Tie Game" );
       numTie = numTie + 1;
   } else {
       System.out.println( " ---- House Won ---- " );
   }

   do{
       System.out.print( "Do you wish to play " +
               "another hand (y/n):" );
       again = in.nextLine();
       again = again.toLowerCase();
       c = again.charAt( 0 );
   }while( c != 'y' && c != 'n' );

   } while ( c == 'y' );

   System.out.println( "========== Results ==========" );
   System.out.println( "Games: " + numGames );
   System.out.println( "Wins: " + numWon );
   System.out.println( "Ties: " + numTie );
}
}