jeops.examples.factorial
Class Fact

java.lang.Object
  |
  +--jeops.examples.factorial.Fact

public class Fact
extends java.lang.Object

Class used to solve the factorial problem (N!) with JEOPS.

Author:
Carlos Figueira Filho (csff@cin.ufpe.br)

Field Summary
private  int n
          The number whose factorial we are trying to find.
private  boolean ok
          Flag indicating whether this problem is already solved.
private  int result
          The factorial of n.
private  Fact subProblem
          The factorial of (n - 1).
 
Constructor Summary
Fact(int n)
          Class constructor.
 
Method Summary
 int getN()
          Returns the number whose factorial we are trying to find.
 int getResult()
          Returns the factorial of n.
 Fact getSubProblem()
          Returns the factorial of (n - 1).
 boolean isOk()
          Checks whether this problem is already solved.
 void setResult(int value)
          Defines the factorial of n.
 void setSubProblem(Fact value)
          Defines the factorial of (n - 1).
 java.lang.String toString()
          Returns a String representation of this problem.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

n

private int n
The number whose factorial we are trying to find.

ok

private boolean ok
Flag indicating whether this problem is already solved.

result

private int result
The factorial of n.

subProblem

private Fact subProblem
The factorial of (n - 1).
Constructor Detail

Fact

public Fact(int n)
Class constructor.
Parameters:
n - the number whose factorial we are trying to find.
Method Detail

getN

public int getN()
Returns the number whose factorial we are trying to find.
Returns:
the number whose factorial we are trying to find.

getResult

public int getResult()
Returns the factorial of n.
Returns:
the factorial of n.

getSubProblem

public Fact getSubProblem()
Returns the factorial of (n - 1).
Returns:
the factorial of (n - 1).

isOk

public boolean isOk()
Checks whether this problem is already solved.
Returns:
true if this problem is already solved; false otherwise.

setResult

public void setResult(int value)
Defines the factorial of n.
Parameters:
value - the factorial of n.

setSubProblem

public void setSubProblem(Fact value)
Defines the factorial of (n - 1).
Parameters:
value - the factorial of (n - 1).

toString

public java.lang.String toString()
Returns a String representation of this problem. Useful for debugging.
Overrides:
toString in class java.lang.Object
Returns:
a String representation of this problem.