mardi 15 novembre 2016

Changing a string array depending on an if statement

My knowledge of coding is very new and basic, but I am writing a hobby program and need some help. I have searched for the answer to my question but sometimes I am even finding it difficult what question to ask!

What I'm currently trying to do is to name a randomly selected creature in a list accordingly depending on whether its a group or not. This is what I have so far-

    String[] grouptype=  {"a","a group of"};
    String group = grouptype[ran.nextInt(grouptype.length)];

    if ("a".equals(group)) { 
        String[] creaturename = {"bee" , "elf" , "goblins"}
    }
    else {
      String[] creaturename = {"bees", "elves", "goblins"};
    }

So far this statement does not appear to work at all- I'd like the second array group to be where I pick a creature name from if group = "a". I apologize for my poor skills but I'd appreciate help, even if its help formatting my questions as I'm sure I will have many more in the future.

Aucun commentaire:

Enregistrer un commentaire