All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.lotspiech.poker.StraightCalculator

java.lang.Object
   |
   +----com.lotspiech.poker.StraightCalculator

public class StraightCalculator
extends Object
This class is used to calculate straights and straight flushes.

Copyright 2001, 2002 by Jeffrey B. Lotspiech. This program is open source; it is licensed under the Common Public License Version 0.5.

Author:
Jeffrey B. Lotspiech

Variable Index

 o COPYRIGHT
 o draw
 o fromDeck
 o have
 o wild

Constructor Index

 o StraightCalculator(int[], int[], int, int)
This method was created in VisualAge.

Method Index

 o countRun(int, int, int, int)
This function is a used subroutine in the straight and straight flush calculations.
 o straight()
This calculates straights the normal way.
 o straightByHighCard()
This calculates straight by actual high card.

Variables

 o COPYRIGHT
 private static final String COPYRIGHT
 o have
 private int have[]
 o fromDeck
 private int fromDeck[]
 o draw
 private int draw
 o wild
 private int wild

Constructors

 o StraightCalculator
 public StraightCalculator(int have[],
                           int fromDeck[],
                           int draw,
                           int wild)
This method was created in VisualAge.

Parameters:
have - Cards that we already have, by rank.
fromDeck - Cards available from the deck, by rank.
draw - Number of cards to be drawn.
wild - Number of wild cards available to fill gaps.

Methods

 o countRun
 private int countRun(int rank,
                      int run,
                      int draw,
                      int gap)
This function is a used subroutine in the straight and straight flush calculations. It is recursive.

 o straight
 public int[] straight()
This calculates straights the normal way. In other words, if there are gaps at the end, they are assumed to be at the high end (ace, king, etc.).

Returns:
The counts for each starting rank. An ace/five straight is shown as starting as "five".
 o straightByHighCard
 public int[] straightByHighCard()
This calculates straight by actual high card. In normal straight calculation, we are concerned about how high a straight we can make. However, for the purpose of taking straights out of other hands, we want to know the actual highest card. In other words, we don't want any wild cards to make the straight higher than the highest actual card.


All Packages  Class Hierarchy  This Package  Previous  Next  Index