package simulatedAnnealing;

/** A city represents an (x,y) cordinate and a name */
public class City implements java.io.Serializable {
  private String name;
  private double x;
  private double y;

/** constructs a city */
  public City() {
  }

/** constructs and initializes a city
  @param name  the name of the city
  @param x  the x coordinate
  @param y  the y coordinate */
  public City(String name,double x,double y){
    this.name=name;
    this.x=x;
    this.y=y;
  }

/** constructs and initializes a city
  @param x  the x coordinate
  @param y  the y coordinate */
  public City(double x,double y) {
    this(null,x,y);
  }

/** constructs and initializes a city from a given city
  @param city  the given city */
  public City(City city) {
    this(city.name,city.x,city.y);
  }

/** getName - returns the name of the city */
  public final String getName() {
    return name;
  }

/** getX - returns the x coordinate of the city */
  public final double getX() {
    return x;
  }

/** getY - returns the y coordinate of the city */
  public final double getY() {
    return y;
  }

/** distance - calculates the distance between two cities
  @param city1 first city
  @param city2 second city */
  public static double distance (City city1, City city2) {
    return (java.lang.Math.sqrt((city1.x - city2.x)*(city1.x - city2.x) +
				(city1.y - city2.y)*(city1.y - city2.y)));
  }
}

