First commit

Former-commit-id: 9340873f9cfb15264004c32d6e4b8f8bd6828d94
Former-commit-id: 1916747c109876aa064412e01204c3aeda9bbbc0
This commit is contained in:
Song Minjae
2016-02-05 13:36:35 +09:00
commit d5c99aad5e
1340 changed files with 298157 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
package com.Torvald.Rand;
import java.util.Random;
/**
* Created by minjaesong on 16-02-03.
*/
public class FudgeDice {
private Random randfunc;
private int diceCounts;
/**
* Define new set of fudge dice with given counts.
* @param randfunc
* @param counts amount of die
*/
public FudgeDice(Random randfunc, int counts) {
this.randfunc = randfunc;
diceCounts = counts;
}
/**
* Roll dice and get result. Range: [-3, 3] for three dice
* @return
*/
public int roll() {
int diceResult = 0;
for (int c = 0; c < diceCounts; c++) {
diceResult += rollSingleDie();
}
return diceResult;
}
/**
* @return random [-1, 0, 1]
*/
private int rollSingleDie() {
return (randfunc.nextInt(3)) - 1;
}
}