lundi 22 avril 2019

How do i create a method which grabs a random value from a String array? [duplicate]

This question already has an answer here:

I am writing a small OOP for the card game Mafia. Right now, I'm trying to create a Method that will: grab a random value(a role) from the array, role, and return it. Thanks so much in advance.

Here is the array

public static String[] role = {"Mafia", "Angel", "Cop", "Civilian"};

Below is what I currently have for my Method of grabbing a random value, as you can see, I'm clueless on what to write up next lol.

public static String[] role() {
    Random randomRole = new Random();
}




Aucun commentaire:

Enregistrer un commentaire