Back to project page 101AndroidApps.
The source code is released under:
Licenced under the Creative Commons Attribution 4.0 licence. For full text see http://creativecommons.org/licenses/by/4.0/
If you think the Android project 101AndroidApps listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.hulzenga.ioi.android.app_003; /*from w w w . ja va 2s . c o m*/ import java.util.Random; /** * Simple static class spitting out random monster names */ class MonsterGenerator { // random inputs for the monster names private static final String[] MONSTER_PREFIX = {"", "Hell", "Infernal", "Vorpal", "Murderous", "Razor", "Foul", "Oozing", ""}; private static final String[] MONSTER_TYPE = {"Lizard", "Saurus", "Bunny", "Gerbil", "Raven", "Skinpecker", "Night Terror"}; private static final String[] MONSTER_POSTFIX = {"", "of the Crannerbog", "from the Eastern Wilds", "of the Great Spire", "from the Abyss", "stuck betwixt worlds", "of the Nether"}; private static Random mRandom = new Random(); // private constructor cannot be instantiated private MonsterGenerator() { } /** * Creates a new random monster name based on a random mix of hardcoded pre- * and postfixes combined with a basic monster type * * @return random monster name */ public static String randomMonster() { return (pickRandom(MONSTER_PREFIX) + " " + pickRandom(MONSTER_TYPE) + " " + pickRandom(MONSTER_POSTFIX)).trim(); } private static String pickRandom(String[] wordList) { return wordList[mRandom.nextInt(wordList.length)]; } }