diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/RandomWordGenerator.java b/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/RandomWordGenerator.java new file mode 100644 index 0000000..83aec6a --- /dev/null +++ b/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/RandomWordGenerator.java @@ -0,0 +1,141 @@ +package uulm.teamname.marvelous.server.lobbymanager; + +import java.util.Locale; +import java.util.Random; + +public class RandomWordGenerator { + + + private static Random random = new Random(); + + public static String generateTwoWords() { + var firstWord = randomWords[random.nextInt(randomWords.length)]; + var secondWord = randomWords[random.nextInt(randomWords.length)]; + while (firstWord.equals(secondWord)) { + secondWord = randomWords[random.nextInt(randomWords.length)]; + } + + firstWord = firstWord.substring(0, 1).toUpperCase() + firstWord.substring(1).toLowerCase(); + secondWord = secondWord.substring(0, 1).toUpperCase() + secondWord.substring(1).toLowerCase(); + return firstWord + secondWord; + + } + + + private static final String[] randomWords = new String[] { + "wait", + "release", + "river", + "important", + "mark", + "electric", + "defective", + "poke", + "blue", + "beef", + "spring", + "hurt", + "orange", + "happy", + "zealous", + "flowery", + "accurate", + "brake", + "title", + "x-ray", + "festive", + "wrathful", + "scissors", + "peaceful", + "finicky", + "shape", + "soothe", + "head", + "spotted", + "needless", + "time", + "abundant", + "humdrum", + "mouth", + "trot", + "bounce", + "thank", + "avoid", + "shocking", + "minor", + "secret", + "rabbit", + "protect", + "honey", + "business", + "worthless", + "suggest", + "splendid", + "drab", + "safe", + "gigantic", + "arrive", + "drum", + "hate", + "dinosaurs", + "bore", + "tired", + "regret", + "fit", + "potato", + "confuse", + "childlike", + "vein", + "sound", + "attack", + "exchange", + "back", + "check", + "damaged", + "grandmother", + "division", + "groovy", + "throat", + "office", + "pin", + "stare", + "meddle", + "shivering", + "interfere", + "occur", + "hole", + "sugar", + "test", + "blind", + "free", + "perform", + "cherries", + "flavor", + "stupendous", + "purpose", + "extend", + "risk", + "fanatical", + "grubby", + "beg", + "romantic", + "outrageous", + "swift", + "bath", + "room", + "pocket", + "front", + "flower", + "quicksand", + "mark", + "sturdy", + "resolute", + "letters", + "expert", + "hapless", + "bloody", + "blue-eyed", + "hope", + "chew", + }; +} diff --git a/Server/src/test/java/uulm/teamname/marvelous/server/lobbymanager/RandomWordGeneratorTest.java b/Server/src/test/java/uulm/teamname/marvelous/server/lobbymanager/RandomWordGeneratorTest.java new file mode 100644 index 0000000..05893b4 --- /dev/null +++ b/Server/src/test/java/uulm/teamname/marvelous/server/lobbymanager/RandomWordGeneratorTest.java @@ -0,0 +1,17 @@ +package uulm.teamname.marvelous.server.lobbymanager; + +import org.junit.jupiter.api.Test; + +import static org.mockito.Mockito.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.assertj.core.api.Assertions.*; + +class RandomWordGeneratorTest { + + @Test + void generatesAString() { + // System.out.println(RandomWordGenerator.generateTwoWords()); + assertThat(RandomWordGenerator.generateTwoWords()).isInstanceOf(String.class); + } + +}