public class Roulette
extends java.lang.Object
This class implements a generic roulette.
Constructor and Description |
---|
Roulette(int num)
Constructs a roulette.
|
Modifier and Type | Method and Description |
---|---|
void |
add(double num)
Enter a new probability in the roulette.
|
void |
print()
Prints the roulette
|
void |
reset()
Resets the roulette (puts all the probabilities to 0).
|
int |
selectRoulette()
Select on position of the roulette and returns it.
|
public Roulette(int num)
Constructs a roulette. It inicializes all its values to 0, and the pointer to the first position. To use it, you have to update all the relative probabilities (not the sum).
num
- is the number of the elements in the roulette.public void add(double num)
Enter a new probability in the roulette. It has to be a relative probability and not a sum, because it performs the sum internally.
num
- is the new probability.public void reset()
Resets the roulette (puts all the probabilities to 0).
public int selectRoulette()
Select on position of the roulette and returns it.
public void print()
Prints the roulette