import java.lang.*; /** * This class contains the information about the towns and their distances. * * coding: h.sarg * modified: 01/98 */ public class TravelData { /** * hold the towns information */ private int[][] towns; /** * holds the coordinates of the towns */ private int[][] coordinates; /** * holds the distances between the towns */ private double[][] distance; /** * number of towns */ private int size; /** * grid size */ private int grid; /** * This constructor creates the towns by random or uses the user-selected * towns. Also the distances between the towns are calculated. * @param data object DialogData */ public TravelData(DialogData data) { size = data.towns; towns = data.townarray; grid = data.grid; coordinates=new int[size][2]; distance=new double[size][size]; int i,j; int count=0; boolean valid=true; //no towns set from the user, set towns randomly if(towns==null) valid=false; if(!valid) { towns=new int[grid][grid]; initArray(); while(count0) { coordinates[count][0]=i; coordinates[count][1]=j; count++; } } } if (!valid) { towns=null; } //compute the distance between the towns checkdistance(); } /** * evaluates the distance between all towns */ private void checkdistance() { int i; int j; double xdiff; double ydiff; for(i=0;i