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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
POUSSARDIN Malo
Poussardin Malo-Game of life Template
Commits
538d361d
Commit
538d361d
authored
5 months ago
by
POUSSARDIN Malo
Browse files
Options
Downloads
Patches
Plain Diff
fin tp6
parent
fb1d1cf7
No related branches found
No related tags found
No related merge requests found
Pipeline
#40508
failed
5 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/ConstantMatrixInitializer.java
+3
-4
3 additions, 4 deletions
src/main/java/matrix/ConstantMatrixInitializer.java
src/main/java/matrix/ListMatrix.java
+20
-10
20 additions, 10 deletions
src/main/java/matrix/ListMatrix.java
with
23 additions
and
14 deletions
src/main/java/matrix/ConstantMatrixInitializer.java
+
3
−
4
View file @
538d361d
...
...
@@ -2,15 +2,14 @@ package matrix;
public
class
ConstantMatrixInitializer
<
T
>
implements
MatrixInitializer
<
T
>
{
// TODO: add instance variables
private
final
T
value
;
public
ConstantMatrixInitializer
(
T
constant
)
{
// TODO
this
.
value
=
constant
;
}
@Override
public
T
initialValueAt
(
Coordinate
coordinate
)
{
// TODO
return
null
;
return
value
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/matrix/ListMatrix.java
+
20
−
10
View file @
538d361d
package
matrix
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -23,11 +24,19 @@ public class ListMatrix<T> implements Matrix<T> {
* @param initializer A matrix initializer to set values in the {@link ListMatrix}.
*/
public
ListMatrix
(
int
width
,
int
height
,
MatrixInitializer
<
T
>
initializer
)
{
// TODO
this
.
width
=
0
;
this
.
height
=
0
;
this
.
matrix
=
null
;
this
.
initializeWith
(
initializer
);
// fills the matrix using initializer
this
.
initializeWith
(
initializer
);
for
(
int
i
=
0
;
i
<
height
;
i
++)
{
List
<
T
>
row
=
new
ArrayList
<>(
width
);
for
(
int
j
=
0
;
j
<
width
;
j
++)
{
row
.
add
(
null
);
}
matrix
.
add
(
row
);
}
this
.
initializeWith
(
initializer
);
}
public
ListMatrix
(
int
width
,
int
height
,
T
constant
)
{
...
...
@@ -35,29 +44,30 @@ public class ListMatrix<T> implements Matrix<T> {
}
private
void
initializeWith
(
MatrixInitializer
<
T
>
initializer
)
{
// TODO initialize each cell of the matrix, with a value determined by initializer
for
(
int
i
=
0
;
i
<
matrix
.
size
();
i
++)
{
for
(
int
j
=
0
;
j
<
matrix
.
get
(
i
).
size
();
j
++)
{
matrix
.
get
(
i
).
set
(
j
,
initializer
.
initialValueAt
(
Coordinate
.
of
(
i
,
j
)));
}
}
}
public
int
width
()
{
// TODO
return
0
;
return
width
;
}
public
int
height
()
{
// TODO
return
0
;
return
height
;
}
@Override
public
T
get
(
int
x
,
int
y
)
{
// TODO
return
null
;
return
matrix
.
get
(
x
).
get
(
y
);
}
@Override
public
void
set
(
int
x
,
int
y
,
T
newValue
)
{
// TODO
matrix
.
get
(
x
).
set
(
y
,
newValue
);
}
}
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