import java.util.Vector;
import java.util.concurrent.ThreadLocalRandom;

public class CityContainer {

	private Vector<City> container = new Vector<City>();
	private int numOfCities;
	
	private static final int min = 1;
	private static final int max = 10000;
	
	public CityContainer(int numOfCities){
		
		int tempx;
		int tempy;
		
		this.numOfCities = numOfCities;
		
		for (int i = 0; i < numOfCities; i++) {
			tempx = ThreadLocalRandom.current().nextInt(min,max+1);
			tempy = ThreadLocalRandom.current().nextInt(min,max+1);
			City tempCity = new City(tempx, tempy, i+1);
			tempCity.printCity();
			this.container.addElement(tempCity);
			}
	}
	
	public double[][] distanceOfCities(){
		
		double[][] temp = new double[this.numOfCities][this.numOfCities];
		
		for(int i=0;i<this.numOfCities;i++){
			for(int j=0;j<this.numOfCities;j++){
				temp[i][j] = getDistance(this.container.get(i), this.container.get(j));
			}
		}
		return  temp;
		
	}
	
	private double getDistance(City city1, City city2){

		double distance = Math.sqrt(Math.pow((city2.GetX()-city1.GetX()), 2) + Math.pow(city2.GetY() - city1.GetY(), 2));
		
		return distance;
		
	}
	
	public City getCity(int i){
		return container.get(i);
	}
	
}
