org.dolben.MarkN
Class Numbah

java.lang.Object
  extended by org.dolben.MarkN.Numbah
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
NumberSequence

public class Numbah
extends java.lang.Object
implements java.lang.Cloneable

This is an N Digit Number. Note that it is called "Numbah" (the New England pronunciation) to disambiguate it from java.lang.Number without having to use the whole name.


Constructor Summary
Numbah()
          constructs a number
 
Method Summary
 java.lang.Object clone()
          makes a new copy of this number
 void copy(Numbah n)
          copies a given number into this one
 int getDigit(int place)
          gets the digit in a given place
static Numbah random()
          makes a pseudorandom number
 Score score(Numbah guess)
          scores a guess with this number as the target
 void setDigit(int digit, int place)
          sets a digit of this number
 java.lang.String toString()
          makes a string of the digits in this number
 boolean valid()
          tests the validity of this number (no two digits the same)
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Numbah

public Numbah()
constructs a number

Method Detail

clone

public java.lang.Object clone()
makes a new copy of this number

Overrides:
clone in class java.lang.Object
Returns:
the copy

copy

public void copy(Numbah n)
copies a given number into this one

Parameters:
n - the number to be copied

setDigit

public void setDigit(int digit,
                     int place)
sets a digit of this number

Parameters:
digit - the new digit
place - the place to set

valid

public boolean valid()
tests the validity of this number (no two digits the same)

Returns:
true iff this number is valid

getDigit

public int getDigit(int place)
gets the digit in a given place

Parameters:
place - which digit to get
Returns:
the digit

random

public static Numbah random()
makes a pseudorandom number

Returns:
the pseudorandom number

toString

public java.lang.String toString()
makes a string of the digits in this number

Overrides:
toString in class java.lang.Object
Returns:
the string of the digits in this number

score

public Score score(Numbah guess)
scores a guess with this number as the target

Parameters:
guess - the guess to score
Returns:
the score