Advertisement
Guest User

GrumpsGenerator

a guest
Feb 16th, 2013
4,339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.29 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class GrumpsGenerator {
  4.  
  5.   private final String INTRO_START = "Welcome back to";
  6.   private final String OUTRO_START = "Next time on";
  7.  
  8.   private final String[] NAMES = { "Game Grumps", "Gample Gust", "Grep",
  9.       "Gash Garst", "Gurp Gurp Gurp Gurp", "Squidward", "Batman",
  10.       "Grumble Dumps", "Groomp Croomp", "Gargarsh", "Grusput", "Goof Troop" };
  11.   private final int UPPERCASE_NAMES = 0;
  12.  
  13.   private final String[] LINE_STARTS = { "OH IT'S A",
  14.       "ROLLING AROUND AT THE SPEED OF", "POPPY BROTHERS JUNIOR",
  15.       "WHAT IS THIS?", "Look at this", "Look at that dang-ass", "Real talk?",
  16.       "I legitimately think", "I hate when", "Pause balls by going upstairs," };
  17.   private final int UPPERCASE_LINE_STARTS = 4;
  18.  
  19.   private final String[] LINE_ENDS = { "IT'S NO USE", "BARRY, PUT THAT IN",
  20.       "POPPY BROTHERS SENIOR", "WE ALWAYS RESET TOGETHER", "GREATGREATGREAT",
  21.       "WHAT IS MY LIFE?", "Pumbloom", "dang", "game feel", "Silver",
  22.       "*Jon coughs*", "[JON NO]", "Chiz Peetza" };
  23.   private final int UPPERCASE_LINE_ENDS = 6;
  24.  
  25.   private Random random;
  26.  
  27.   private StringBuilder sb;
  28.  
  29.   private int lineCount;
  30.  
  31.   public GrumpsGenerator() {
  32.     random = new Random();
  33.  
  34.     sb = new StringBuilder();
  35.  
  36.     generateIntro();
  37.  
  38.     lineCount = random.nextInt(30) + 5;
  39.  
  40.     generateLines(lineCount);
  41.  
  42.     generateOutro();
  43.   }
  44.  
  45.   public void generateIntro() {
  46.     String intro = INTRO_START + " " + NAMES[random.nextInt(NAMES.length)];
  47.  
  48.     sb.append(intro + "\n");
  49.   }
  50.  
  51.   public void generateLines(int n) {
  52.     for (int i = 0; i < n; i++) {
  53.       int lineStartIndex = random.nextInt(LINE_STARTS.length);
  54.       int lineEndIndex = random.nextInt(LINE_ENDS.length);
  55.  
  56.       String line = LINE_STARTS[lineStartIndex] + " " + LINE_ENDS[lineEndIndex];
  57.  
  58.       if (lineStartIndex < UPPERCASE_LINE_STARTS
  59.           || lineEndIndex < UPPERCASE_LINE_ENDS)
  60.         line = line.toUpperCase();
  61.  
  62.       sb.append(line + "\n");
  63.     }
  64.   }
  65.  
  66.   public void generateOutro() {
  67.     String outro = OUTRO_START + " " + NAMES[random.nextInt(NAMES.length)];
  68.  
  69.     sb.append(outro + "\n");
  70.   }
  71.  
  72.   @Override
  73.   public String toString() {
  74.     return sb.toString();
  75.   }
  76.  
  77.   public static void main(String[] args) {
  78.     System.out.println(new GrumpsGenerator());
  79.   }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement