feat: implemented RandomWordGenerator
This commit is contained in:
		@ -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",
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
@ -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);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user