Java Random randomInsults()

Here you can find the source of randomInsults()

Description

random Insults

License

Open Source License

Declaration

public static Iterator<String> randomInsults() 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    public static Iterator<String> randomInsults() {
        return randomInsults(42);
    }//from  w w  w . j  a v  a2s .c om

    /** http://iome.me/fz/need%20a%20random%20sentence?/why%20not%20zoidberg? */
    public static Iterator<String> randomInsults(final int seed) {
        final HashSet<String> seen = new HashSet<>();
        final String[] adj1 = { "warped", "babbling", "madcap", "whining", "wretched", "loggerheaded", "threadbare",
                "foul", "artless", "artless", "baudy", "beslumbering", "bootless", "churlish", "clouted", "craven",
                "dankish", "dissembling", "droning", "errant", "fawning", "fobbing", "froward", "frothy",
                "gleeking", "goatish", "gorbellied", "impertinent", "infectious", "jarring", "loggerheaded",
                "lumpish", "mammering", "mangled", "mewling", "paunchy", "pribbling", "puking", "puny", "qualling",
                "rank", "reeky", "roguish", "rutting", "saucy", "spleeny", "spongy", "surly", "tottering",
                "unmuzzled", "vain", "venomed", "villainous", "warped", "wayward", "weedy", "yeasty" };
        final String[] adj2 = { "toad-spotted", "guts-griping", "beef-witted", "ill-favored", "hare-brained",
                "fat-kidneyed", "white-bearded", "shrill-voiced", "base-court", "bat-fowling", "beef-witted",
                "beetle-headed", "boil-brained", "clapper-clawed", "clay-brained", "common-kissing", "crook-pated",
                "dismal-dreaming", "dizzy-eyed", "doghearted", "dread-bolted", "earth-vexing", "elf-skinned",
                "fat-kidneyed", "fen-sucked", "flap-mouthed", "fly-bitten", "folly-fallen", "fool-born",
                "full-gorged", "guts-griping", "half-faced", "hasty-witted", "hedge-born", "hell-hated",
                "idle-headed", "ill-breeding", "ill-nurtured", "knotty-pated", "milk-livered", "motley-minded",
                "onion-eyed", "plume-plucked", "pottle-deep", "pox-marked", "reeling-ripe", "rough-hewn",
                "rude-growing", "rump-fed", "shard-borne", "sheep-biting", "spur-galled", "swag-bellied",
                "tardy-gaited", "tickle-brained", "toad-spotted", "unchin-snouted", "weather-bitten" };
        final String[] nouns = { "jolt-head", "mountain-goat", "fat-belly", "malt-worm", "minnow", "so-and-so",
                "maggot-pie", "foot-licker", "land-fish", "apple-john", "baggage", "barnacle", "bladder",
                "boar-pig", "bugbear", "bum-bailey", "canker-blossom", "clack-dish", "clotpole", "coxcomb",
                "codpiece", "death-token", "dewberry", "flap-dragon", "flax-wench", "flirt-gill", "foot-licker",
                "fustilarian", "giglet", "gudgeon", "haggard", "harpy", "hedge-pig", "horn-beast", "hugger-mugger",
                "joithead", "lewdster", "lout", "maggot-pie", "malt-worm", "mammet", "measle", "minnow",
                "miscreant", "moldwarp", "mumble-news", "nut-hook", "pigeon-egg", "pignut", "puttock", "pumpion",
                "ratsbane", "scut", "skainsmate", "strumpet", "varlot", "vassal", "whey-face", "wagtail", };
        return new Iterator<String>() {
            private Random random = new Random(seed);

            @Override
            public boolean hasNext() {
                return true;
            }

            @Override
            public String next() {
                String a1 = adj1[random.nextInt(adj1.length)];
                String a2 = adj2[random.nextInt(adj2.length)];
                String n = nouns[random.nextInt(nouns.length)];
                String candidate = "Curse thee, KBP, thou " + a1 + " " + a2 + " " + n;
                if (seen.contains(candidate)) {
                    return next();
                } else {
                    seen.add(candidate);
                    return candidate;
                }
            }

            @Override
            public void remove() {
            }
        };
    }
}

Related

  1. randomIcon()
  2. randomID()
  3. randomId()
  4. randomIndices(Random r, int minCount, int maxCount)
  5. randomInRange(double min, double max)
  6. randomIntArray(int len, Random rand)
  7. randomIntegerList(int sz, int min, int max)
  8. randomIntegers(int sz)
  9. randomIterable(Collection col)