1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
| /*
* TSPville.java
*
* Created on 19 novembre 2007, 12:07
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package tsp;
/**
*Cette classe définit une ville par des coordonnées dans un plan et un nom.
*elle possède également un indicateur de parcours afin d'indiquer si on est déja passer par cette ville
*
*@since 18/11/07
*@version 1.0 11/07
*@author LEFEBVRE Arnaud
*/
public class TSPville {
private ville city;
private boolean prc;
/** Creates a new instance of TSPville */
public TSPville()
{
city = new ville();
prc = false;
}
public TSPville(int xc , int yc )
{
city = new ville(xc,yc);
prc = false;
}
public TSPville(int xc , int yc , String nom)
{
city = new ville(xc,yc,nom);
prc = false;
}
public TSPville(int xc, int yc ,String nom, boolean b)
{
city = new ville(xc,yc,nom);
prc = b;
}
public TSPville(TSPville v)
{
city = new ville(v.getX(),v.getY(),v.getName());
prc = v.getPrc();
}
public int getX()
{
return city.getX();
}
public int getY()
{
return city.getY();
}
public String getName()
{
return city.getName();
}
public boolean getPrc()
{
return prc;
}
public void display()
{
System.out.println("Absicce : "+getX());
System.out.println("ordonnée : "+getY());
System.out.println("Nom : "+getName());
}
public void setX(int xc)
{
city.setX(xc);
}
public void setY(int yc)
{
city.setY(yc);
}
public void setName(String nom)
{
city.setName(nom);
}
public void setCoord(int xc , int yc)
{
city.setX(xc);
city.setY(yc);
}
public void setPrc(boolean b)
{
prc = b;
}
public void setAll(int xc, int yc, String nom)
{
city.setX(xc);
city.setY(yc);
city.setName(nom);
}
public TSPville clone()
{
return new TSPville(getX(),getY(),getName(),prc);
}
public boolean equals(Object o)
{
if (!(o instanceof TSPville))
return false;
else
{
boolean result=true;
TSPville v = (TSPville) o;
if (! (v.getX() == this.getX()))
{
result = false;
}
else if (!(v.getY() == this.getY()))
{
result = false;
}
else if (!(this.getName().equalsIgnoreCase(v.getName())))
{
result = false;
}
else if (! (this.prc == v.getPrc() ) )
{
result = false;
}
return result;
}
}
} |
Partager