# Random Insult Generator - Really Need Help

GobiasMoleman
I need to make this Random Insult Generator work... I mistakenly thought it had compiled correctly, but I guess something went wrong. I would really appreciate some help with this as soon as possible. Thanks (I apologize for the sloppy code, I just saw Java code for the first time a few weeks ago, so this is pretty alien to me):

//InsultGenerator
//A program to generate insults.

import java.text.*;
import java.util.*;
import java.util.Random;

public class InsultGenerator
{//start
public static void main(String[] args)
{//start main
//variables
Random choice =new Random();
int a = choice.nextInt(adj.length);
int b = choice.nextInt(verb.length);
int c = choice.nextInt(noun.length);
//insult
{//start insult
String adj[] = { "poxmarked", "cantankerous", "bilestained", "scruffy looking"};
String verb[] = {"goatstealing"};
String noun[] = {"nerf herder", "blackguard"};
}//end insult
//Text
System.out.println("You "+adj[a]+", "+verb+" "+noun[n]+".");}
}//end main

## Answers and Replies

rx7_drifter
I need to make this Random Insult Generator work... I mistakenly thought it had compiled correctly, but I guess something went wrong. I would really appreciate some help with this as soon as possible. Thanks (I apologize for the sloppy code, I just saw Java code for the first time a few weeks ago, so this is pretty alien to me):

It would help to know what your error was :\

I never used Java but if it's a syntax error you're getting:

Random choice =new Random();

Put a space between '=' and 'new'.

Staff Emeritus
Gold Member
Side note: 'goatstealing' is an adjective, not a verb.

Homework Helper
I wonder what this program can possibly be used for...

Homework Helper
I wonder what this program can possibly be used for...

You would wonder that, you poxmarked, goatstealing blackguard!

Mentor
I am not terribly familiar with Java, but it looks like you are using the length of adj verb and noun before they are defined.

At the line
int a = choice.nextInt(adj.length);
the variable adj has not been defined so its length is also undefined (or at best 0)

Homework Helper
it looks like you are using the length of adj verb and noun before they are defined.

Yes, and the insult section doesn't need braces (though I don't think they hurt).

_Mayday_
:rofl: Those are some weak insults.

Is this an attempt at an artificial Rodney Dangerfield ? That's not AI ...hehe it lacks the I part ... j/k

it's a good start at programming.
Half is learning the silly syntax, half is learning what the routine is doing.
I always found the first half harder.

Mentor
:rofl: Those are some weak insults.
Yeah, but in our over-sensitive politically-correct world a really good one would probably get you expelled

_Mayday_
Damn right!

Mentor
Side note: 'goatstealing' is an adjective, not a verb.

It can be used for either, right? I was called a goatstealing fiend after I got caught goatstealing.

rootX
Do testing
Some suggestions:

Code:
public static void main(String[] args)
{//start main
//variables
String adj[] = { "poxmarked", "cantankerous", "bilestained", "scruffy looking"};
String verb[] = {"goatstealing"};
String noun[] = {"nerf herder", "blackguard"};

Random choice =new Random();
int a = choice.nextInt(adj.length);
int b = choice.nextInt(verb.length);
int c = choice.nextInt(noun.length);
//Text
System.out.println("You "+adj[a]+", "+verb[b]+" "+noun[n]+".");
}

Code:
public static void main(String[] args)
{//start main
//variables
String adj[] = { "poxmarked", "cantankerous", "bilestained", "scruffy looking"};
String verb[] = {"goatstealing"};
String noun[] = {"nerf herder", "blackguard"};

//Text
System.out.println("You "+adj[0]+", "+verb[0]+" "+noun[0]+".");
}

Code:
public static void main(String[] args)
{//start main
//variables
String adj[] = { "poxmarked", "cantankerous", "bilestained", "scruffy looking"};
String verb[] = {"goatstealing"};
String noun[] = {"nerf herder", "blackguard"};

Random choice =new Random();
int a = choice.nextInt(adj.length);
int b = choice.nextInt(verb.length);
int c = choice.nextInt(noun.length);
System.out.println(" a = "+a+" b = "+b+" c = "+c);
}

If you don't find any problem, try compiling again or use different computer .. or restart ;)