Skip to content
Snippets Groups Projects
Commit 2dc6df6c authored by Guyslain's avatar Guyslain
Browse files

section 2 Coordinate terminée

parent ac3e3620
Branches
No related tags found
No related merge requests found
...@@ -16,8 +16,7 @@ public record Coordinate(int x, int y) { ...@@ -16,8 +16,7 @@ public record Coordinate(int x, int y) {
* @return A new {@link Coordinate} instance. * @return A new {@link Coordinate} instance.
*/ */
public static Coordinate of(int x, int y) { public static Coordinate of(int x, int y) {
// TODO: compléter ce fabriquant return new Coordinate(x,y);
return null;
} }
/** /**
...@@ -26,8 +25,7 @@ public record Coordinate(int x, int y) { ...@@ -26,8 +25,7 @@ public record Coordinate(int x, int y) {
* @return The left adjacent {@link Coordinate}. * @return The left adjacent {@link Coordinate}.
*/ */
public Coordinate left() { public Coordinate left() {
// TODO: à compléter return new Coordinate(this.x - 1, this.y);
return null;
} }
/** /**
...@@ -36,8 +34,7 @@ public record Coordinate(int x, int y) { ...@@ -36,8 +34,7 @@ public record Coordinate(int x, int y) {
* @return The right adjacent {@link Coordinate}. * @return The right adjacent {@link Coordinate}.
*/ */
public Coordinate right() { public Coordinate right() {
// TODO: à compléter return new Coordinate(this.x + 1, this.y);
return null;
} }
/** /**
...@@ -46,8 +43,7 @@ public record Coordinate(int x, int y) { ...@@ -46,8 +43,7 @@ public record Coordinate(int x, int y) {
* @return The above adjacent {@link Coordinate}. * @return The above adjacent {@link Coordinate}.
*/ */
public Coordinate above() { public Coordinate above() {
// TODO: à compléter return new Coordinate(this.x, this.y + 1);
return null;
} }
/** /**
...@@ -56,8 +52,7 @@ public record Coordinate(int x, int y) { ...@@ -56,8 +52,7 @@ public record Coordinate(int x, int y) {
* @return The below adjacent {@link Coordinate}. * @return The below adjacent {@link Coordinate}.
*/ */
public Coordinate below() { public Coordinate below() {
// TODO: à compléter return new Coordinate(this.x, this.y - 1);
return null;
} }
/** /**
...@@ -66,8 +61,12 @@ public record Coordinate(int x, int y) { ...@@ -66,8 +61,12 @@ public record Coordinate(int x, int y) {
* @return A list of orthogonal neighboring {@link Coordinate}s. * @return A list of orthogonal neighboring {@link Coordinate}s.
*/ */
public List<Coordinate> orthogonalNeighbours() { public List<Coordinate> orthogonalNeighbours() {
// TODO: à compléter return List.of(
return List.of(); this.right(),
this.above(),
this.left(),
this.below()
);
} }
/** /**
...@@ -76,8 +75,12 @@ public record Coordinate(int x, int y) { ...@@ -76,8 +75,12 @@ public record Coordinate(int x, int y) {
* @return A list of diagonal neighboring {@link Coordinate}s. * @return A list of diagonal neighboring {@link Coordinate}s.
*/ */
public List<Coordinate> diagonalNeighbours() { public List<Coordinate> diagonalNeighbours() {
// TODO: à compléter return List.of(
return List.of(); this.right().above(),
this.left().above(),
this.left().below(),
this.right().below()
);
} }
/** /**
...@@ -86,8 +89,10 @@ public record Coordinate(int x, int y) { ...@@ -86,8 +89,10 @@ public record Coordinate(int x, int y) {
* @return A list of all neighboring {@link Coordinate}s. * @return A list of all neighboring {@link Coordinate}s.
*/ */
public List<Coordinate> orthodiagonalNeighbours() { public List<Coordinate> orthodiagonalNeighbours() {
// TODO: à compléter List<Coordinate> neighbours = new ArrayList<>();
return List.of(); neighbours.addAll(this.orthogonalNeighbours());
neighbours.addAll(this.diagonalNeighbours());
return neighbours;
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment