Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SAHIN 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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SAHIN Melis damla
SAHIN Game of life Template
Commits
bd8c7028
Commit
bd8c7028
authored
7 months ago
by
SAHIN Melis damla
Browse files
Options
Downloads
Patches
Plain Diff
Compléter la classe CoordinateIterator
parent
aefbcb2e
No related branches found
No related tags found
No related merge requests found
Pipeline
#38279
failed
7 months ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/matrix/CoordinateIterator.java
+18
-6
18 additions, 6 deletions
src/main/java/matrix/CoordinateIterator.java
with
18 additions
and
6 deletions
src/main/java/matrix/CoordinateIterator.java
+
18
−
6
View file @
bd8c7028
...
@@ -8,7 +8,9 @@ import java.util.NoSuchElementException;
...
@@ -8,7 +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 +18,8 @@ class CoordinateIterator implements Iterator<Coordinate> {
...
@@ -16,7 +18,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 +29,7 @@ class CoordinateIterator implements Iterator<Coordinate> {
...
@@ -26,8 +29,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 +40,17 @@ class CoordinateIterator implements Iterator<Coordinate> {
...
@@ -38,7 +40,17 @@ 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
;
// on crée un méthode update
update
();
return
next
;
}
private
void
update
(){
current
=
current
.
right
();
if
(
current
.
x
()
==
width
)
current
=
new
Coordinate
(
0
,
current
.
y
()+
1
);
}
}
}
}
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