I have the slight problem at the moment with my Java code that I can't pick up a random string from an array I have. A segment of my code is here:
private static String core;
{
String[] insults = new String[15];
insults[0] = "So's your mum.";
insults[1] = "I hate you too.";
insults[2] = "Freak!";
insults[3] = "Your balls are like peas.";
insults[4] = "You're so ugly, your birth certificate was an apology letter from the condom factory.";
insults[5] = "Ooh, take me to the burn unit.";
insults[6] = "That insult was like your dick- Pathetic.";
insults[7] = "Your mum looks like a dog. I was brought up not to lie.";
insults[8] = "Can you look away? It's killing my face...";
insults[9] = "If you had a house for every good insult you gave me, you'd still be living on the streets!";
insults[10] = "Shut up, you'll never be the man your mother is.";
insults[11] = "Shut up, you'll never be the man your mother is.";
insults[12] = "Oh my God... Was your face squashed in a vice at birth?";
insults[13] = "I know you are, but what am I?";
insults[14] = "Oh, okay then...";
double count = 0;
};
public static void output(String output) {
String insult1 = tpiCore.core[(new Random()).nextInt(insults.length)];
}
You can probably see from here what I'm trying to do. Pick a random insult from the list up above. If I try and run the code, it throws an error at tpiCore.core[(new Random()).nextInt(insults.length)];, "saying that The type of the expression must be an array type but it resolved to String". Then, when I change the type to Array, it throws up all kinds of errors along the core class. I don't know what I'm doing wrong. Can anyone help?
tpiCore? 2. what is that instruction block under the declaration ofcoresupposed to do?String insult1 = tpiCore.core[(new Random()).nextInt(insults.length)];looks very dangerous...