|
Evaluating Software Design Patterns — the "Gang of Four" patterns implemented in Java 6 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectdk.rode.thesis.facade.MathFacade
@Participant(value="Facade") public class MathFacade
A math facade is a small math library that represents an-easy-to-use high-level interface for complex mathematical functions. (yeah, right...)
Facade usage is thread-safe.
Implementation notes:
The small examples used throughout this thesis does not really
justify use of Facade; they are simply not complex enough. Still,
this Facade implementation address several issues discussed by
Gamma et al. [Gamma95, p.185-193]:
sequences
are too verbose and tedious to be implemented by any client, and hence
this facade help provide the desired functionality, shielding clients
from the gory details.
| Field Summary | |
|---|---|
private Map<Integer,AckermannSequence> |
ackermann
A map storing calculated Ackermann values, A(m,n), per m value. |
private static MathFacade |
instance
The singleton instance to use. |
private ReversiblePrimeSequence |
primes
The prime sequence to deliver the prime numbers. |
private UnboundedRandomSequence |
random
An unbounded random sequence that uses a Fibonacci sequence as the seed. |
| Constructor Summary | |
|---|---|
private |
MathFacade()
Private constructor as this class is a singleton. |
| Method Summary | |
|---|---|
int |
getAckermannNumber(int m,
int n)
Returns the value of the Ackermann function, A(m,n), for m and n values supplied as m and n,
respectively. |
static MathFacade |
getInstance()
Returns the math library to use. |
BigInteger |
getNthFibonnaciNumber(int n)
Returns the n'th Fibonacci number. |
int |
getNthPrimeNumber(int n)
Returns the n'th prime number. |
boolean |
getRandomBoolean()
Returns a pseudo random boolean value. |
BigInteger |
getRandomFibonnaciNumber(int n)
Returns a random Fibonacci number between the first and the n'th number. |
long |
getRandomNumber()
Returns a random number. |
int |
getRandomNumber(int highBound)
Return a pseudo random number between one and highBound. |
int |
getRandomNumber(int lowBound,
int highBound)
Return a pseudo random number between lowBound and
highBound. |
int |
getRandomPrimeNumber(int n)
Returns a random prime number between the first and the n'th prime number. |
String |
toString()
Return the string representation of this facade. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private Map<Integer,AckermannSequence> ackermann
Never null.
private static final MathFacade instance
Never null.
@ParticipantUsage(value="SubsystemClass",
type=ReversiblePrimeSequence.class)
private ReversiblePrimeSequence primes
Will "grow in size" as needed.
Lazily created.
private final UnboundedRandomSequence random
Never null.
| Constructor Detail |
|---|
private MathFacade()
| Method Detail |
|---|
public int getAckermannNumber(int m,
int n)
m and n,
respectively.
m - The m value for the Ackermann function; cannot be negative.n - The n value for the Ackermann function; cannot be negative.
IllegalArgumentException - If m or n are illegal.public static final MathFacade getInstance()
public BigInteger getNthFibonnaciNumber(int n)
n - Identifies the Fibonacci number to return; cannot be smaller than one.
IllegalArgumentException - If n is smaller than one.public int getNthPrimeNumber(int n)
n - Identifies the prime number to return; cannot be smaller than one.
IllegalArgumentException - If n is smaller than one.public boolean getRandomBoolean()
public BigInteger getRandomFibonnaciNumber(int n)
n'th number.
n - The maximum number to return; cannot be smaller than one.
n'th number.
IllegalArgumentException - If n is smaller than one.public long getRandomNumber()
public int getRandomNumber(int highBound)
highBound.
highBound - The high bound.
IllegalArgumentException - If highBound is smaller than
one.
public int getRandomNumber(int lowBound,
int highBound)
lowBound and
highBound.
lowBound - The low bound.highBound - The high bound.
IllegalArgumentException - If highBound is smaller than
lowBound.public int getRandomPrimeNumber(int n)
n'th prime number.
n - The maximum number to return; cannot be smaller than one.
n'th prime number.
IllegalArgumentException - If n is smaller than one.public String toString()
toString in class Object
|
Gunni Rode / rode.dk | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||