This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
package sudoku.structure;
|
package sudoku.structure;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Représente les coordonnées d'une Cell
|
* Représente les coordonnées d'une Cell.
|
||||||
*/
|
*/
|
||||||
public class Coordinate {
|
public class Coordinate {
|
||||||
|
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="ATTRIBUTS">
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* L'abscisse de la Cell.
|
* L'abscisse de la Cell.
|
||||||
*/
|
*/
|
||||||
@@ -14,6 +16,10 @@ public class Coordinate {
|
|||||||
*/
|
*/
|
||||||
private int y;
|
private int y;
|
||||||
|
|
||||||
|
// </editor-fold>
|
||||||
|
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="METHODES">
|
||||||
|
|
||||||
public Coordinate(int x, int y) {
|
public Coordinate(int x, int y) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
@@ -35,16 +41,23 @@ public class Coordinate {
|
|||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int calculateIndex(int size) {
|
/**
|
||||||
return this.y * size + this.x;
|
* Ajoute la Coordiante donnée à celle-ci.
|
||||||
}
|
* @param other Coordiante, à ajouter.
|
||||||
|
* @return Coordinate, le résultat de l'addition.
|
||||||
|
*/
|
||||||
public Coordinate add(Coordinate other) {
|
public Coordinate add(Coordinate other) {
|
||||||
return new Coordinate(this.x + other.x, this.y + other.y);
|
return new Coordinate(this.x + other.x, this.y + other.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Soustrait la Coordiante donnée à celle-ci.
|
||||||
|
* @param other Coordiante, à soustraire.
|
||||||
|
* @return Coordinate, le résultat de la soustraction.
|
||||||
|
*/
|
||||||
public Coordinate sub(Coordinate other) {
|
public Coordinate sub(Coordinate other) {
|
||||||
return new Coordinate(this.x - other.x, this.y - other.y);
|
return new Coordinate(this.x - other.x, this.y - other.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// </editor-fold>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user