package org.project.location;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;

public class Location {
    private ArrayList<String> locations;
    private Random random;
    ArrayList<Integer> key=new ArrayList<>();
    
    public Location() {
        random = new Random();
        locations = new ArrayList<>(Arrays.asList(
            " Shire", " Rivendell", " Lothlórien", 
            " Gondor", " Mordor", " Isengard", 
            " Moria", " Minas Morgul", " Paths of the Dead"
        ));
        for(int i=0; i<9; i++)
        {
            key.add(1);
        }
    }

    public Location(int i)
    {
        key.add(0);
    }
    
    public String chooseLocation() {
        return locations.get(random.nextInt(locations.size()));
    }
    
    public boolean thereIsKey()
    {
        int i= random.nextInt(key.size()*2);
        if (i<key.size() && key.get(i)==1) {
            key.set(i,0);
            return true;
        }
        else
            return false;
    }
}