public class PerfectShuffler
extends java.lang.Object
A perfect shuffle is one where the deck is cut perfectly in half and then "riffled" together alternating one card from each half like the teeth of a zipper before being pushed together. This is considered to be one of the most difficult sleights of hand in card magic, and it allows the performer to control the positions of all cards in the deck, rearranging the permutation in unexpected ways. There are two perfect shuffles that differ according to whether the first card down comes from the top or bottom half. A perfect out-shuffle leaves the top card on top, that is, outside the deck. A perfect in-shuffle leaves the top card at the second card, that is, inside the deck.
public String toString() specification: toString should return a comma-and-space-separated list of the current permutation of deck indices (0-51). The easiest way to do this is to make use of the Arrays.toString() method and return the result without the first ("[") and last ("]") characters.
Constructor and Description |
---|
PerfectShuffler()
Initialize an array with 52-card deck indices such that index i contains integer i.
|
Modifier and Type | Method and Description |
---|---|
int |
getIndexAt(int index)
Return the current card index at the given index.
|
void |
inShuffle()
Perform a perfect in-shuffle on the deck indices.
|
static void |
main(java.lang.String[] args)
Create a PerfectShuffler object and print it.
|
void |
outShuffle()
Perform a perfect out-shuffle on the deck indices.
|
java.lang.String |
toString() |
public PerfectShuffler()
public void inShuffle()
public void outShuffle()
public int getIndexAt(int index)
index
- the given deck indexpublic java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)
args
- (unused)