jeudi 3 août 2017

I am trying to get a random item from an array that is in an ArrayList

I am at the beginning stages of creating what I think should essentially be an easy little program. However, I am very new to java so it is proving to be more difficult than expected. This is what I have that will compile except for the printing part at the end. Firstly, I don't understand why not? secondly, I need to create a random generator to randomly pick an item from one of the arrays within the arrayList. I have been trying so many things but just can't get it to work. I think I am confused as to where to even put the code. HELP!

import java.util.*;

public class RestaurantSelector1 {

    //public static class Tribeca4star{
    final static String[] italian = {"Pepolino Restaurant", "Locanda Verde", "Scalini Fedeli", "Gran Morsi", "Ecco", "Tutto il Giorno", "The Odeon", "Mamo Restaurant", "Petrarca Cucina E Vino", "Osteria Morini"};
    final static String[] japanese = {"Shigure", "Sushi Azabu", "Ichimura", "Brushstroke", "Takahachi Tribeca Restaurant", "Ninja New York", "DOMODOMO", "Sushi of Gari", "Hirohisa", "Blue Ribbon"};
    final static String[] french = {"Bouley", "Batard", "Racines", "The Odeon", "MAMO Restaurant", "La Sirene", "Le Coucou", "Balthazar", "Taureau", "L'Appart"};
    final static String[] american = {"American Cut Steakhouse", "Marc Forgione", "The Bennett", "Little Park", "The Odeon", "Yves", "Tribeca Grill", "Atera", "Batard", "Brandy Library"};
    final static String[] chinese = {"Mr. Chow", "Macao", "Khe-Yo"};
    final static String[] spanish = {"Tablao", "Sazon", "Despana", "Estancia 460", "Westside Coffee Shop", "Anejo Tribeca", "Terra Wine Bar", "Darlene", "Sophia's Cuban Cuisine", "Amada"};
    final static String[] cafe = { "Arcade Bakery", "Galerie de Cafe", "The Wooly Daily", "Cafe Belle", "Baked", "Laughing Man Coffee and Tea","La Colombe Coffee", "Kuro-Obi at Canal Street Market", "Blue Spoon Coffee", "Everyman Espresso"};
    final static String[] thai = {"khe-yo", "Empire", "Macao"};
    final static String[] indian = {"Tamarind"};
    final static String[] viatnamese = {"Khe-Yo", "Macao"};

    public static void main(String[] args){
        ArrayList<String[]> cuisine = new ArrayList<>();

        cuisine.add(italian);
        cuisine.add(japanese);
        cuisine.add(french);
        cuisine.add(american);
        cuisine.add(chinese);
        cuisine.add(spanish);
        cuisine.add(cafe);
        cuisine.add(thai);
        cuisine.add(indian);
        cuisine.add(viatnamese);

        System.out.println(cuisine[0,1]);
    }
}




Aucun commentaire:

Enregistrer un commentaire