mirror of
https://github.com/Noratrieb/UselessClasses.git
synced 2026-01-14 08:35:10 +01:00
j a v a d o c f o r g o o d r a n d o m
This commit is contained in:
parent
095fb3ee15
commit
1b968a4940
2 changed files with 23 additions and 11 deletions
|
|
@ -5,21 +5,10 @@
|
|||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/19.0.0/annotations-19.0.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="library" name="Maven: com.github.shinixsensei-dev:OpenTDB4j:1.1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.json:json:20200518" level="project" />
|
||||
</component>
|
||||
|
|
|
|||
|
|
@ -16,18 +16,36 @@ public class GoodRandom {
|
|||
|
||||
OpenTDB trivia = new OpenTDB();
|
||||
|
||||
/**
|
||||
* Create a new {@code GoodRandom} with a seed
|
||||
* @param seed The seed
|
||||
*/
|
||||
public GoodRandom(int seed) {
|
||||
trivia.setCategory(seed % 20 + 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@code GoodRandom}
|
||||
*/
|
||||
public GoodRandom() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a random integer from 0 to {@code max}. Integers are not distributed equally if {@code max} is not a power of 2.
|
||||
* @param max The maximum number
|
||||
* @return A random Integer from 0 to {@code max}
|
||||
*/
|
||||
public int randomInt(int max){
|
||||
return randomInt(0, max);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a random integer from {@code min} to {@code max}. Integers are not distributed equally if {@code max} - {@code min} is not a power of 2.
|
||||
* @param min The minimum number
|
||||
* @param max The maximum number
|
||||
* @return A random Integer from 0 to {@code max}
|
||||
*/
|
||||
public int randomInt(int min, int max){
|
||||
int range = max - min;
|
||||
//exponent of next biggest power of two
|
||||
|
|
@ -41,6 +59,11 @@ public class GoodRandom {
|
|||
return resultNormalized + min;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a random number from 0 to 3 using OpenTDB. It pulls a random trivia question,
|
||||
* sorts the answers alphabetically and returns the position of the correct answer
|
||||
* @return A random number from 0 to 3
|
||||
*/
|
||||
private int getFourDigit(){
|
||||
trivia.getTrivia();
|
||||
ArrayList<String> answers = new ArrayList<>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue