diff --git a/README.md b/README.md index d8169c8447c883f8a41b7dc74fe9e607ad2ea3d7..5061ded5098291d4d9eb155e45ac6c69b539cfb9 100644 --- a/README.md +++ b/README.md @@ -19,5 +19,5 @@ jeu de la vie. ## Membre du projet -- NOM, prénom, du participant +- SAHIN, Melis Damla, du participant diff --git a/src/main/java/matrix/Coordinate.java b/src/main/java/matrix/Coordinate.java index f3e5ac009ee837b1c3998c6b1f033e42019669b6..8bd880244e858907285df5203cea6de4385e4a04 100644 --- a/src/main/java/matrix/Coordinate.java +++ b/src/main/java/matrix/Coordinate.java @@ -15,8 +15,7 @@ public record Coordinate(int x, int y) { * @return A new {@link Coordinate} instance. */ public static Coordinate of(int x, int y) { - // TODO: compléter ce fabriquant - return null; + return new Coordinate(x,y); } /** @@ -25,8 +24,7 @@ public record Coordinate(int x, int y) { * @return The left adjacent {@link Coordinate}. */ public Coordinate left() { - // TODO: à compléter - return null; + return new Coordinate(x-1,y); } /** @@ -35,8 +33,7 @@ public record Coordinate(int x, int y) { * @return The right adjacent {@link Coordinate}. */ public Coordinate right() { - // TODO: à compléter - return null; + return new Coordinate(x+1, y); } /** @@ -45,8 +42,7 @@ public record Coordinate(int x, int y) { * @return The above adjacent {@link Coordinate}. */ public Coordinate above() { - // TODO: à compléter - return null; + return new Coordinate(x, y+1); } /** @@ -55,8 +51,7 @@ public record Coordinate(int x, int y) { * @return The below adjacent {@link Coordinate}. */ public Coordinate below() { - // TODO: à compléter - return null; + return new Coordinate(x, y-1); } /** @@ -73,8 +68,7 @@ public record Coordinate(int x, int y) { * @return A list of orthogonal neighboring {@link Coordinate}s. */ public List<Coordinate> orthogonalNeighbours() { - // TODO: à compléter - return List.of(); + return List.of(left(),right(), above(), below()); } /** @@ -92,8 +86,10 @@ public record Coordinate(int x, int y) { * @return A list of diagonal neighboring {@link Coordinate}s. */ public List<Coordinate> diagonalNeighbours() { - // TODO: à compléter - return List.of(); + return List.of(new Coordinate(x-1, y-1), + new Coordinate(x-1, y+1), + new Coordinate(x+1, y-1), + new Coordinate(x+1, y+1)); } /** @@ -111,8 +107,10 @@ public record Coordinate(int x, int y) { * @return A list of all neighboring {@link Coordinate}s. */ public List<Coordinate> orthodiagonalNeighbours() { - // TODO: à compléter - return List.of(); + return List.of(left(),right(), above(), below(), new Coordinate(x-1, y-1), + new Coordinate(x-1, y+1), + new Coordinate(x+1, y-1), + new Coordinate(x+1, y+1)); } @Override