Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Poussardin Malo-Game of life Template
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
POUSSARDIN Malo
Poussardin Malo-Game of life Template
Commits
fb1d1cf7
Commit
fb1d1cf7
authored
7 months ago
by
POUSSARDIN Malo
Browse files
Options
Downloads
Patches
Plain Diff
étape 3
parent
e2517c6c
No related branches found
No related tags found
No related merge requests found
Pipeline
#38337
failed
7 months ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/matrix/Coordinate.java
+16
-16
16 additions, 16 deletions
src/main/java/matrix/Coordinate.java
src/main/java/matrix/CoordinateIterator.java
+17
-7
17 additions, 7 deletions
src/main/java/matrix/CoordinateIterator.java
with
33 additions
and
23 deletions
src/main/java/matrix/Coordinate.java
+
16
−
16
View file @
fb1d1cf7
...
...
@@ -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,11 @@ 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 +108,11 @@ 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
...
...
This diff is collapsed.
Click to expand it.
src/main/java/matrix/CoordinateIterator.java
+
17
−
7
View file @
fb1d1cf7
...
...
@@ -8,7 +8,10 @@ import java.util.NoSuchElementException;
* height range.
*/
class
CoordinateIterator
implements
Iterator
<
Coordinate
>
{
private
int
width
;
private
int
height
;
private
int
curretentx
=
0
;
private
int
currenty
=
0
;
/**
* Creates a new {@link CoordinateIterator} with the specified width and height.
*
...
...
@@ -16,8 +19,8 @@ class CoordinateIterator implements Iterator<Coordinate> {
* @param height The height of the coordinate range.
*/
public
CoordinateIterator
(
int
width
,
int
height
)
{
// TODO: à compléter
}
this
.
width
=
width
;
this
.
height
=
height
;
}
/**
* Checks if there are more {@link Coordinate}s to iterate over.
...
...
@@ -26,8 +29,7 @@ class CoordinateIterator implements Iterator<Coordinate> {
*/
@Override
public
boolean
hasNext
()
{
// TODO: à compléter
return
false
;
return
currenty
<
height
;
}
/**
...
...
@@ -38,7 +40,15 @@ class CoordinateIterator implements Iterator<Coordinate> {
*/
@Override
public
Coordinate
next
()
{
// TODO: à compléter
return
null
;
if
(!
hasNext
())
{
throw
new
NoSuchElementException
(
"No more Elements"
);
}
Coordinate
coordinates
=
new
Coordinate
(
curretentx
,
currenty
);
curretentx
++;
if
(
curretentx
>=
width
)
{
curretentx
=
0
;
currenty
++;
}
return
coordinates
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment