Skip to content
Snippets Groups Projects
Commit 9d6561d6 authored by BALME Maxence's avatar BALME Maxence
Browse files

avancée

parent d9b9952d
No related branches found
No related tags found
No related merge requests found
Pipeline #38296 failed
...@@ -15,8 +15,7 @@ public record Coordinate(int x, int y) { ...@@ -15,8 +15,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;
} }
/** /**
...@@ -25,8 +24,7 @@ public record Coordinate(int x, int y) { ...@@ -25,8 +24,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(x-1,y);
return null;
} }
/** /**
...@@ -35,8 +33,7 @@ public record Coordinate(int x, int y) { ...@@ -35,8 +33,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(x+1,y);
return null;
} }
/** /**
...@@ -45,8 +42,7 @@ public record Coordinate(int x, int y) { ...@@ -45,8 +42,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(x,y+1);
return null;
} }
/** /**
...@@ -55,8 +51,7 @@ public record Coordinate(int x, int y) { ...@@ -55,8 +51,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(x,y-1);
return null;
} }
/** /**
...@@ -73,8 +68,7 @@ public record Coordinate(int x, int y) { ...@@ -73,8 +68,7 @@ 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(above(),right(),left(),below());
return List.of();
} }
/** /**
...@@ -92,8 +86,7 @@ public record Coordinate(int x, int y) { ...@@ -92,8 +86,7 @@ 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(new Coordinate(x-1,y-1),new Coordinate(x-1,y+1),new Coordinate(x+1,y-1),new Coordinate(x+1,y+1));
return List.of();
} }
/** /**
...@@ -111,8 +104,7 @@ public record Coordinate(int x, int y) { ...@@ -111,8 +104,7 @@ 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 return List.of(above(),right(),left(),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));
return List.of();
} }
@Override @Override
......
...@@ -8,6 +8,9 @@ import java.util.NoSuchElementException; ...@@ -8,6 +8,9 @@ import java.util.NoSuchElementException;
* height range. * height range.
*/ */
class CoordinateIterator implements Iterator<Coordinate> { class CoordinateIterator implements Iterator<Coordinate> {
private final int width;
private final int height;
private Coordinate current = new Coordinate(0, 0);
/** /**
* Creates a new {@link CoordinateIterator} with the specified width and height. * Creates a new {@link CoordinateIterator} with the specified width and height.
...@@ -16,7 +19,8 @@ class CoordinateIterator implements Iterator<Coordinate> { ...@@ -16,7 +19,8 @@ class CoordinateIterator implements Iterator<Coordinate> {
* @param height The height of the coordinate range. * @param height The height of the coordinate range.
*/ */
public CoordinateIterator(int width, int height) { public CoordinateIterator(int width, int height) {
// TODO: à compléter this.width = width;
this.height = height;
} }
/** /**
...@@ -26,8 +30,7 @@ class CoordinateIterator implements Iterator<Coordinate> { ...@@ -26,8 +30,7 @@ class CoordinateIterator implements Iterator<Coordinate> {
*/ */
@Override @Override
public boolean hasNext() { public boolean hasNext() {
// TODO: à compléter return current.y() < height;
return false;
} }
/** /**
...@@ -38,7 +41,11 @@ class CoordinateIterator implements Iterator<Coordinate> { ...@@ -38,7 +41,11 @@ class CoordinateIterator implements Iterator<Coordinate> {
*/ */
@Override @Override
public Coordinate next() { public Coordinate next() {
// TODO: à compléter if (!hasNext()) throw new NoSuchElementException();
return null; Coordinate next = current;
current = current.right();
if (current.x() == width) current = new Coordinate(0, current.y() + 1);
return next;
} }
} }
\ No newline at end of file
...@@ -39,13 +39,11 @@ public class ListMatrix<T> implements Matrix<T> { ...@@ -39,13 +39,11 @@ public class ListMatrix<T> implements Matrix<T> {
} }
public int width() { public int width() {
// TODO return width;
return 0;
} }
public int height() { public int height() {
// TODO return height;
return 0;
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment