import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;
/**
 *\brief Trida slouzici k nacitani mest z programu CityGenerator
 * @author nemec
 *
 */
public class CityLoader {
	
	private int numOfCities;
	private double[][] distances;
	/**
	 * Konstruktor ktery nacita tabulku vzdalenosti mezi jednotlivymi mesty
	 * @param path Cesta k souboru se vzdalenostmi
	 * @throws IOException
	 */
	public CityLoader(String path) throws IOException{
		
		Scanner scanner = new Scanner(new FileReader(path));
		this.numOfCities = Integer.parseInt(scanner.next());
		
		//System.out.println(numOfCities);
		
		this.distances = new double[this.numOfCities][this.numOfCities];
		
		while(scanner.hasNext()){
			for(int i=0;i<this.numOfCities;i++){
				for(int j=0;j<this.numOfCities;j++){
					this.distances[i][j]=Double.parseDouble(scanner.next());
					//System.out.printf("%5d ",this.distances[i][j]);
				}
				//System.out.println();
			}
		
		}
		
		scanner.close();
		System.out.println("Map: " + path + " with size of " + this.numOfCities + " was loaded!");
		System.out.println("--------------------------------------------------------------------------");
	}
	/**
	 * Funkce, ktera vraci nactenou tabulku vzdalenosti
	 * @return Tabulka vzdalenosti mezi jednotlivymi mesty
	 */
	public double[][] getDistances(){
		return this.distances;
	}
	/**
	 * Funkce, ktera vraci pocest mest
	 * @return Pocet mest
	 */
	public int getNumOfCities(){
		return this.numOfCities;
	}

}
