mirror of
https://github.com/Noratrieb/UselessClasses.git
synced 2026-01-14 16:45:09 +01:00
finally, some good fucking random
This commit is contained in:
parent
95834b3586
commit
a395a0dc98
15 changed files with 170 additions and 4 deletions
16
.idea/compiler.xml
generated
Normal file
16
.idea/compiler.xml
generated
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="RetardedClasses" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel>
|
||||
<module name="RetardedClasses" target="14" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/discord.xml
generated
Normal file
6
.idea/discord.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="PROJECT_FILES" />
|
||||
</component>
|
||||
</project>
|
||||
20
.idea/jarRepositories.xml
generated
Normal file
20
.idea/jarRepositories.xml
generated
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
13
.idea/libraries/Maven__com_github_shinixsensei_dev_OpenTDB4j_1_1_0.xml
generated
Normal file
13
.idea/libraries/Maven__com_github_shinixsensei_dev_OpenTDB4j_1_1_0.xml
generated
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: com.github.shinixsensei-dev:OpenTDB4j:1.1.0">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/shinixsensei-dev/OpenTDB4j/1.1.0/OpenTDB4j-1.1.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/shinixsensei-dev/OpenTDB4j/1.1.0/OpenTDB4j-1.1.0-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/shinixsensei-dev/OpenTDB4j/1.1.0/OpenTDB4j-1.1.0-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
13
.idea/libraries/Maven__org_json_json_20200518.xml
generated
Normal file
13
.idea/libraries/Maven__org_json_json_20200518.xml
generated
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: org.json:json:20200518">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/json/json/20200518/json-20200518.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/json/json/20200518/json-20200518-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/json/json/20200518/json-20200518-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
7
.idea/misc.xml
generated
7
.idea/misc.xml
generated
|
|
@ -1,5 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_14" default="true" project-jdk-name="openjdk-14" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_14">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<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" />
|
||||
|
|
@ -16,5 +20,7 @@
|
|||
<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>
|
||||
</module>
|
||||
25
pom.xml
Normal file
25
pom.xml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.github.nilstrieb</groupId>
|
||||
<artifactId>RetardedClasses</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>14</maven.compiler.source>
|
||||
<maven.compiler.target>14</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.shinixsensei-dev</groupId>
|
||||
<artifactId>OpenTDB4j</artifactId>
|
||||
<version>1.1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -16,6 +16,7 @@ public class Buddy {
|
|||
|
||||
public Buddy(String name) {
|
||||
this.name = name;
|
||||
setSCREAM();
|
||||
}
|
||||
|
||||
public void help(){
|
||||
54
src/main/java/GoodRandom.java
Normal file
54
src/main/java/GoodRandom.java
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
import Requests.OpenTDB;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Generates random numbers based on OpenTDB trivia results. Should not be used too often. Should not be used actually.
|
||||
*
|
||||
* <p>
|
||||
* Every trivia question has 4 answers, giving us a random number out of 4 for every question
|
||||
* 2 question can give an octal digit, which can be converted to an int
|
||||
* 200IQ move, ik
|
||||
* </p>
|
||||
*/
|
||||
public class GoodRandom {
|
||||
|
||||
OpenTDB trivia = new OpenTDB();
|
||||
|
||||
public GoodRandom(int seed) {
|
||||
trivia.setCategory(seed % 20 + 10);
|
||||
}
|
||||
|
||||
public GoodRandom() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public int randomInt(int max){
|
||||
return randomInt(0, max);
|
||||
}
|
||||
|
||||
public int randomInt(int min, int max){
|
||||
int range = max - min;
|
||||
//exponent of next biggest power of two
|
||||
int digits = (int) Math.ceil(Math.log(range)/Math.log(2));
|
||||
int twoDigits = (int) Math.ceil(digits / 2d);
|
||||
int resultNumber = 0;
|
||||
for (int i = 0; i < twoDigits; i++) {
|
||||
resultNumber += Math.pow(4, i) * getFourDigit();
|
||||
}
|
||||
int resultNormalized = resultNumber % range;
|
||||
return resultNormalized += min;
|
||||
}
|
||||
|
||||
private int getFourDigit(){
|
||||
trivia.getTrivia();
|
||||
ArrayList<String> answers = new ArrayList<>();
|
||||
answers.add(trivia.getCorrectAnswer());
|
||||
answers.add(trivia.getIncorrectAnswers()[0]);
|
||||
answers.add(trivia.getIncorrectAnswers()[1]);
|
||||
answers.add(trivia.getIncorrectAnswers()[2]);
|
||||
answers.sort(null);
|
||||
return answers.indexOf(trivia.getCorrectAnswer());
|
||||
}
|
||||
}
|
||||
|
|
@ -15,5 +15,10 @@ public class TestClass {
|
|||
Buddy bobby = new Buddy("bobby");
|
||||
bobby.help();
|
||||
bobby.joke();
|
||||
|
||||
GoodRandom random = new GoodRandom();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
System.out.println(random.randomInt(20));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue