com.thomaso.bridge.impossible
Class ImpossibleBook

java.lang.Object
  |
  +--com.thomaso.bridge.impossible.ImpossibleBook
Direct Known Subclasses:
AndrewsBook, PavlicekBook

public abstract class ImpossibleBook
extends java.lang.Object

An abstract class which, when extended, indexes all possible bridge hands. The main reason to make this an abstract class, rather than an interface, is to allow the definition of getPageAsVector and to record the 'Pages' value.


Field Summary
static java.math.BigInteger Pages
          The number of bridge deals.
 
Constructor Summary
ImpossibleBook()
           
 
Method Summary
abstract  int[] getPage(java.math.BigInteger pageNo)
          Convert an integer between 0 and Pages-1 to a deal.
 int[] getPage(java.lang.String pageString)
          Get a page number from a string.
 java.util.Vector getPageAsVector(java.math.BigInteger pageNo)
          Calls encode then wraps the result as a Vector of Integers.
abstract  java.math.BigInteger index(int[] whom)
          Abstract: Should take a deal and find its index in the book
static void main(ImpossibleBook book, java.lang.String[] args)
          Run a test for a given book.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Pages

public static final java.math.BigInteger Pages
The number of bridge deals.
Constructor Detail

ImpossibleBook

public ImpossibleBook()
Method Detail

getPage

public abstract int[] getPage(java.math.BigInteger pageNo)
Convert an integer between 0 and Pages-1 to a deal. The deal is represented as an array of 52 integers between 0 and 3. The ith element determines who gets the ith card from the deck. This means that this doesn't really determine a deal - you also need a set of hand and card encodings - North=0,East=1,South=2,West=3, AceofSpades=51,...,TwoOfClubs=0 is one such encoding.
Parameters:
pageNo - The page requested.

index

public abstract java.math.BigInteger index(int[] whom)
Abstract: Should take a deal and find its index in the book
Parameters:
whom - An array telling where each cards is placed.

getPageAsVector

public java.util.Vector getPageAsVector(java.math.BigInteger pageNo)
Calls encode then wraps the result as a Vector of Integers.
Parameters:
pageNo - The page number in the book.

getPage

public int[] getPage(java.lang.String pageString)
Get a page number from a string.
Parameters:
pageString - A string containing a page number.

main

public static void main(ImpossibleBook book,
                        java.lang.String[] args)
Run a test for a given book. Each argument is read as an index into the given book, and the page is decoded then encoded again.
Parameters:
book - An implemention of this class
args - A sequence of page numbers to test.